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:6c91481e-6b71-fde8-349d-b76ef44ed1d2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7C4:1A1AB5:FDB9EB:16D84E1:6A5F48B0 |
| html-safe-nonce | 70b9368481921eae6eaf903539f7ae75926674d50ec6dc075d51dfb6b6e514f7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0M0OjFBMUFCNTpGREI5RUI6MTZEODRFMTo2QTVGNDhCMCIsInZpc2l0b3JfaWQiOiIxNDQ1ODE1Nzk2MTE5ODQ5MTM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3fa1eb549fa1c07cf305b3ff0883b6b33d57475d041e749f3be1311e03b662fe |
| 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 | ab2497d9345a59709926b385d88458fa5932c82ec066288448eb68b34cbcbbda |
| 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 | ba0ac57287507693938b0a2de45402a22cda0785 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width