Title: auto-import with `package.json#imports` does not take `moduleResolution` into account · Issue #60405 · microsoft/TypeScript · GitHub
Open Graph Title: auto-import with `package.json#imports` does not take `moduleResolution` into account · Issue #60405 · microsoft/TypeScript
X Title: auto-import with `package.json#imports` does not take `moduleResolution` into account · Issue #60405 · microsoft/TypeScript
Description: 🔎 Search Terms "subpath", "imports", "package.json", "moduleResolution" 🕗 Version & Regression Information This changed in commit or PR #55015 This is the behavior in every version I tried, and I reviewed the FAQ for entries about import...
Open Graph Description: 🔎 Search Terms "subpath", "imports", "package.json", "moduleResolution" 🕗 Version & Regression Information This changed in commit or PR #55015 This is the behavior in every version I tried, and I r...
X Description: 🔎 Search Terms "subpath", "imports", "package.json", "moduleResolution" 🕗 Version & Regression Information This changed in commit or PR #55015 This is th...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/60405
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"auto-import with `package.json#imports` does not take `moduleResolution` into account","articleBody":"### 🔎 Search Terms\n\n\"subpath\", \"imports\", \"package.json\", \"moduleResolution\"\n\n### 🕗 Version \u0026 Regression Information\n\n- This changed in commit or PR #55015\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about imports, completions\n\n\n### ⏯ Playground Link\n\n[alan910127/ts-60405-repro](https://github.com/alan910127/ts-60405-repro)\n\n### 💻 Code\n\n```jsonc\n// package.json\n{\n \"imports\": {\n \"#*\": \"./src/*\"\n },\n \"devDependencies\": {\n \"typescript\": \"5.6.3\"\n }\n}\n```\n\n```jsonc\n// tsconfig.json\n{\n \"compilerOptions\": {\n \"moduleResolution\": \"Bundler\"\n }\n}\n```\n\n```ts\n// src/foo/bar/baz.ts\nexport function baz() {}\n```\n\n```ts\n// src/one/two/three.ts\n// actual - import { baz } from \"#foo/bar/baz.js\";\n// expected - import { baz } from \"#foo/bar/baz\";\n```\n\n\n\n### 🙁 Actual behavior\n\nWhen auto-importing the function `baz` (either through completion or code action), the typescript language server will insert an import statement with a `.js` file extension.\n\n```ts\nimport { baz } from \"#foo/bar/baz.js\";\n```\n\n### 🙂 Expected behavior\n\nSince we are using `\"moduleResolution\": \"Bundler\"`, it should insert an import statement without the `.js` file extension.\n\n```ts\nimport { baz } from \"#foo/bar/baz\";\n```\n\n### Additional information about the issue\n\nI've seen a similar issue #59200, but I cannot reproduce the issue, with the same setup. Therefore, I think my issue might be related with the subpath imports.","author":{"url":"https://github.com/alan910127","@type":"Person","name":"alan910127"},"datePublished":"2024-11-04T07:55:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/60405/TypeScript/issues/60405"}
| 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:5fea9a08-1974-1c27-e2bc-d376934ba3c3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC42:237A75:363E4D:480767:6A617233 |
| html-safe-nonce | cbd7aa023314bbe7593fb09f8058fdf9b8e77abf16aa0d7b947621c632600ae6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzQyOjIzN0E3NTozNjNFNEQ6NDgwNzY3OjZBNjE3MjMzIiwidmlzaXRvcl9pZCI6IjU1Mzk1ODU0MjIxNTMzMTQ4NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2718ea194685649c19c2b93c077144db039b18202f2f1abcb76e00563c0dbbc7 |
| hovercard-subject-tag | issue:2632098476 |
| 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/60405/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d01055a4f468a96a46a229b9f81c4973c5a3c9b485a7f5337e4d86be995f7729/microsoft/TypeScript/issues/60405 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d01055a4f468a96a46a229b9f81c4973c5a3c9b485a7f5337e4d86be995f7729/microsoft/TypeScript/issues/60405 |
| og:image:alt | 🔎 Search Terms "subpath", "imports", "package.json", "moduleResolution" 🕗 Version & Regression Information This changed in commit or PR #55015 This is the behavior in every version I tried, and I r... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alan910127 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b05bb6314e7e93021a7b7dab54a85cbe48d821938e762c1dff815efd60699622 |
| 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 | 94389bfdcd393b0a5a274aee94e8a9739d063fe5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width