Title: [5.5 beta] package.json `"type"` lookup in non-Node.js `module` is unexpected · Issue #58663 · microsoft/TypeScript · GitHub
Open Graph Title: [5.5 beta] package.json `"type"` lookup in non-Node.js `module` is unexpected · Issue #58663 · microsoft/TypeScript
X Title: [5.5 beta] package.json `"type"` lookup in non-Node.js `module` is unexpected · Issue #58663 · microsoft/TypeScript
Description: 🔎 Search Terms moduleDetection force legacy 🕗 Version & Regression Information This changed in version 5.5-beta ⏯ Playground Link No response 💻 Code package.json: { "name": "ts-test", "version": "1.0.0", "description": "", "type": "commo...
Open Graph Description: 🔎 Search Terms moduleDetection force legacy 🕗 Version & Regression Information This changed in version 5.5-beta ⏯ Playground Link No response 💻 Code package.json: { "name": "ts-test", "version": "1...
X Description: 🔎 Search Terms moduleDetection force legacy 🕗 Version & Regression Information This changed in version 5.5-beta ⏯ Playground Link No response 💻 Code package.json: { "name": "ts-t...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/58663
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[5.5 beta] package.json `\"type\"` lookup in non-Node.js `module` is unexpected","articleBody":"### 🔎 Search Terms\n\nmoduleDetection force legacy\n\n### 🕗 Version \u0026 Regression Information\n\n- This changed in version 5.5-beta\n\n### ⏯ Playground Link\n\n_No response_\n\n### 💻 Code\n\npackage.json:\r\n```json\r\n{\r\n \"name\": \"ts-test\",\r\n \"version\": \"1.0.0\",\r\n \"description\": \"\",\r\n \"type\": \"commonjs\",\r\n \"devDependencies\": {\r\n \"typescript\": \"^5.5.0-beta\"\r\n }\r\n}\r\n```\r\ntsconfig.json:\r\n```ts\r\n{\r\n \"include\": [\"src/index.ts\"],\r\n \"compilerOptions\": {\r\n \"module\": \"Preserve\",\r\n \"verbatimModuleSyntax\": true,\r\n \"moduleDetection\": \"force\",\r\n \"emitDeclarationOnly\": true,\r\n \"declaration\": true,\r\n \"declarationDir\": \"./dts\"\r\n }\r\n}\r\n```\r\nsrc/index.ts:\r\n```ts\r\nexport let a = 1;\r\n```\n\n### 🙁 Actual behavior\n\n```\r\nsrc/index.ts:1:1 - error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.\r\n\r\n1 export let a = 1;\r\n```\n\n### 🙂 Expected behavior\n\nGiven that I'm using `\"moduleDetection\": \"force\"`, that file is an ES module (regardless of what `package.json#type` says) and thus I shouldn't see that error. This was the behavior in 5.4.\n\n### Additional information about the issue\n\n_No response_","author":{"url":"https://github.com/nicolo-ribaudo","@type":"Person","name":"nicolo-ribaudo"},"datePublished":"2024-05-26T11:56:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/58663/TypeScript/issues/58663"}
| 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:ff45ddcb-50f3-882f-3ea9-fa1ac0f69979 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8CFE:266F67:5E7D84A:7E8D574:6A5DE9A9 |
| html-safe-nonce | fd15019c81257bac56e81c9e9eb3cdcd5cc5a08a915ab56a9e3a316817f94949 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0ZFOjI2NkY2Nzo1RTdEODRBOjdFOEQ1NzQ6NkE1REU5QTkiLCJ2aXNpdG9yX2lkIjoiNzkxMDY2OTg0Nzg4MTQ0Mzc1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5045cd1b225b137b6c772c5c7ce10229999b443e227178ef031ec7e0f9880806 |
| hovercard-subject-tag | issue:2317666941 |
| 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/58663/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cbc3ed46a8a3f321e4c2a8874e8374d4cb1096d36539077ecddaa7687627afa1/microsoft/TypeScript/issues/58663 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cbc3ed46a8a3f321e4c2a8874e8374d4cb1096d36539077ecddaa7687627afa1/microsoft/TypeScript/issues/58663 |
| og:image:alt | 🔎 Search Terms moduleDetection force legacy 🕗 Version & Regression Information This changed in version 5.5-beta ⏯ Playground Link No response 💻 Code package.json: { "name": "ts-test", "version": "1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nicolo-ribaudo |
| hostname | github.com |
| expected-hostname | github.com |
| None | f068985268f2a1e272fe40dd37a3352a16d337d57ec570e56da6c2346e179f59 |
| 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 | e36408244bcd0ded36f1cfba5db8e97f99c2117e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width