Title: `ts` object has no properties when loading typescript.js in a browser with v5.5-rc · Issue #58893 · microsoft/TypeScript · GitHub
Open Graph Title: `ts` object has no properties when loading typescript.js in a browser with v5.5-rc · Issue #58893 · microsoft/TypeScript
X Title: `ts` object has no properties when loading typescript.js in a browser with v5.5-rc · Issue #58893 · microsoft/TypeScript
Description: Acknowledgement I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion. Comment This came up after sending the initial Google v5.5-beta feedback in #58685 since I was just l...
Open Graph Description: Acknowledgement I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion. Comment This came up after sending the initial Google v5.5-be...
X Description: Acknowledgement I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion. Comment This came up after sending the initial Google v5....
Opengraph URL: https://github.com/microsoft/TypeScript/issues/58893
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`ts` object has no properties when loading typescript.js in a browser with v5.5-rc","articleBody":"### Acknowledgement\n\n- [X] I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.\n\n### Comment\n\nThis came up after sending the initial Google v5.5-beta feedback in https://github.com/Microsoft/TypeScript/issues/58685 since I was just looking at build failures for that feedback.\r\n\r\nApologies if this isn't an officially supported way of using the TypeScript compiler or not - most of the docs I can find are specific to running the compiler via Node.\r\n\r\nGoogle has some internal web apps that load the bundled TSC from https://github.com/microsoft/TypeScript/blob/v5.5-rc/lib/typescript.js file in a browser. One example use case is a tool similar to https://www.typescriptlang.org/play/.\r\n\r\nIn TS 5.5 these apps break at runtime because they call methods on the global `ts` object like `ts.createLanguageService`, but `ts` is now just an empty object with no properties. I narrowed this down to the bundling changes in https://github.com/microsoft/TypeScript/pull/57133. Here's typescript.js before & after:\r\n\r\n[v5.4.2](https://raw.githubusercontent.com/microsoft/TypeScript/v5.4.2/lib/typescript.js):\r\n\r\n``` js\r\nvar ts = (() => {\r\n // lots and lots of code\r\n return require_typescript();\r\n})();\r\n\r\nif (typeof module !== \"undefined\" && module.exports) { module.exports = ts; }\r\n```\r\n\r\n[v5.5-rc](https://raw.githubusercontent.com/microsoft/TypeScript/v5.5-rc/lib/typescript.js):\r\n\r\n``` js\r\nvar ts = {}; ((module) => {\r\n// lots and lots of code\r\nmodule.exports = __toCommonJS(typescript_exports);\r\n// even more code\r\n})(typeof module !== \"undefined\" && module.exports ? module : { exports: ts });\r\nif (typeof module !== \"undefined\" && module.exports) { ts = module.exports; }\r\n```\r\n\r\nI'd assume that in v5.5-rc, `ts` was intended to be instantiated via passing `{exports : ts }` as the `module` argument to this IIFE, causing the exported functions that are put on `module.exports` to also be defined as properties on `ts`. Instead the `module.exports = __toCommonJS(typescript_exports);` assignment just overwrites `ts` in `{exports: ts}` and `ts` is just an empty object.","author":{"url":"https://github.com/lauraharker","@type":"Person","name":"lauraharker"},"datePublished":"2024-06-17T18:28:21Z","url":"https://github.com/microsoft/TypeScript/issues/58893"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f7561738-22d0-9525-73d3-f971ab1f64e2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 88DC:2ACC63:1146D7B:1692A75:6B04F693 |
| html-safe-nonce | dce0ed8d81a0ecf68c079f653131d25f816288b08cc0a62aad689fa2eb89d244 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OERDOjJBQ0M2MzoxMTQ2RDdCOjE2OTJBNzU6NkIwNEY2OTMiLCJ2aXNpdG9yX2lkIjoiMTEzOTU2MTI4MDQ4MzY4NjAzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 872d4ca940fad2c1e74ce9a319f46bece764c3b8336711a3cdf7653218a1655a |
| hovercard-subject-tag | issue:2357971539 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/58893/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dd0f88116798b687ba474918adf8bec96ea63f213c573483908d9cb6676a7554/microsoft/TypeScript/issues/58893 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dd0f88116798b687ba474918adf8bec96ea63f213c573483908d9cb6676a7554/microsoft/TypeScript/issues/58893 |
| og:image:alt | Acknowledgement I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion. Comment This came up after sending the initial Google v5.5-be... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lauraharker |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2c3971d6ab4be607cf9a26ac26ef0a7bfce380ec2ba14642e64028ad07a492b9 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3f1d45dee14b3f87c64e9017a9c08d011561786 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width