Title: Error in ESM about no extensionless imports does not occur for import with only specifier · Issue #52191 · microsoft/TypeScript · GitHub
Open Graph Title: Error in ESM about no extensionless imports does not occur for import with only specifier · Issue #52191 · microsoft/TypeScript
X Title: Error in ESM about no extensionless imports does not occur for import with only specifier · Issue #52191 · microsoft/TypeScript
Description: Bug Report Doing import "./other"; will not raise a Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './other.mjs'? error. 🔎 Search Terms import s...
Open Graph Description: Bug Report Doing import "./other"; will not raise a Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './ot...
X Description: Bug Report Doing import "./other"; will not raise a Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or '...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/52191
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error in ESM about no extensionless imports does not occur for import with only specifier","articleBody":"# Bug Report\r\n\r\nDoing `import \"./other\";` will not raise a `Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './other.mjs'?` error.\r\n\r\n### 🔎 Search Terms\r\n\r\nimport specifier only side effects\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n5.0.0-dev.20230110\r\n\r\n### ⏯ Playground Link\r\n\r\nHere's a repo: https://github.com/dsherret/tsc-issues/tree/importOnlySpecifier\r\n\r\n### 💻 Code\r\n\r\n```json\r\n{\r\n \"compilerOptions\": {\r\n \"moduleResolution\": \"NodeNext\",\r\n \"target\": \"ESNext\",\r\n \"module\": \"NodeNext\",\r\n \"declaration\": true,\r\n \"emitDeclarationOnly\": true,\r\n \"traceResolution\": true\r\n }\r\n}\r\n```\r\n\r\n```ts\r\n// main.mts\r\nimport \"./other\";\r\n\r\n// other.mts\r\nexport class Test {}\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nDoes not error unless I change the import to have a default, namespace, or named import. Output will fail at runtime.\r\n\r\n```\r\n======== Resolving module './other' from 'V:/tsc-issues/main.mts'. ========\r\nExplicitly specified module resolution kind: 'NodeNext'.\r\nResolving in ESM mode with conditions 'node', 'import', 'types'.\r\nLoading module as file / folder, candidate module location 'V:/tsc-issues/other', target file types: TypeScript, JavaScript, Declaration.\r\nDirectory 'V:/tsc-issues/other' does not exist, skipping all lookups in it.\r\n======== Module name './other' was not resolved. ========\r\nFile 'V:/tsc-issues/node_modules/typescript/lib/package.json' does not exist.\r\nFound 'package.json' at 'V:/tsc-issues/node_modules/typescript/package.json'.\r\nFile 'V:/tsc-issues/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.\r\nFile 'V:/tsc-issues/node_modules/typescript/package.json' exists according to earlier cached lookups.\r\n...etc...\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\nShould error because no extension used.\r\n","author":{"url":"https://github.com/dsherret","@type":"Person","name":"dsherret"},"datePublished":"2023-01-10T23:30:50Z","url":"https://github.com/microsoft/TypeScript/issues/52191"}
| 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:cd9da6dd-f13f-e0d9-92a1-c72725cc75b0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AEC2:1DCB8C:108182C:15DBDF4:6B010C30 |
| html-safe-nonce | bc294f7830d07c25f0aeeb17a34c503c50391cfb1cbbb5a201702cd40ef8f6c6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUMyOjFEQ0I4QzoxMDgxODJDOjE1REJERjQ6NkIwMTBDMzAiLCJ2aXNpdG9yX2lkIjoiNDE5MTk3NTkwMTg4NzUzMjA4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e151fc4caccc5015eda20cfbbe4fb3859f73d929c3e758e23dec686c99ec8611 |
| hovercard-subject-tag | issue:1528152847 |
| 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/52191/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a0b8dedbd3698e3c983172d4bda9dade73e5d2e2b03a900ca0d475af8fa4ef16/microsoft/TypeScript/issues/52191 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a0b8dedbd3698e3c983172d4bda9dade73e5d2e2b03a900ca0d475af8fa4ef16/microsoft/TypeScript/issues/52191 |
| og:image:alt | Bug Report Doing import "./other"; will not raise a Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './ot... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dsherret |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width