Title: Change declaration file import paths from `.js` to `.d.ts` · Issue #50629 · microsoft/TypeScript · GitHub
Open Graph Title: Change declaration file import paths from `.js` to `.d.ts` · Issue #50629 · microsoft/TypeScript
X Title: Change declaration file import paths from `.js` to `.d.ts` · Issue #50629 · microsoft/TypeScript
Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Change declaration file import paths from `.js` to `.d.ts` · Issue #50629 · microsoft/TypeScript
Open Graph Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Change declaration file import paths from `.js` to `.d.ts` · Issue #50629 · microsoft/TypeScript
X Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Change declaration file import paths from `.js` to `.d.ts` · Issue #50629 · microsoft/TypeScript
Opengraph URL: https://github.com/microsoft/TypeScript
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Change declaration file import paths from `.js` to `.d.ts`","articleBody":"# Suggestion\r\n\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n-->\r\n\r\n## 🔍 Search Terms\r\n\r\n\u003c!--\r\n 💡 Did you know? TypeScript has over 2,000 open suggestions!\r\n 🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.\r\n The \"Common Feature Requests\" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests\r\n\r\n Replace the text below:\r\n-->\r\n\r\n- `declaration import paths`\r\n- `esnext declaration import path`\r\n\r\nI also know there's a lot of somewhat-related conversation around this area in #37582 and #46452 , but this is only for the output of declaration files, so I'm not sure if it's exactly related to those issues or not. If it is, feel free to close this and accept my apologies. \r\n\r\n## ✅ Viability Checklist\r\n\r\n\u003c!--\r\n Suggestions that don't meet all these criteria are very, very unlikely to be accepted.\r\n We always recommend reviewing the TypeScript design goals before investing time writing\r\n a proposal for ideas outside the scope of the project.\r\n-->\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n\r\n## ⭐ Suggestion\r\n\r\nWhen using TypeScript to `emitDeclarationOnly`, it outputs a `.d.ts` file. However, the contents of that file keep the same import path. An example:\r\n\r\n```ts\r\n// in `index.d.ts`\r\nexport {TestFunc} from './other.js';\r\n```\r\n\r\nWhat would be nice, however, is to have the declaration file import paths point to the actual file, like so:\r\n\r\n```ts\r\n// in `index.d.ts`\r\nexport {TestFunc} from './other.d.ts';\r\n```\r\n\r\nTo maybe help see more clearly, I created [this repo](https://github.com/frehner/typescript-output-testing) that has the current source code and output files when running `npx tsc --emitDeclarationOnly`. You'll note that the [`/types/index.d.ts`](https://github.com/frehner/typescript-output-testing/blob/main/types/index.d.ts) file has an import/export path to a file that doesn't actually exist, but is still found when using something like node's resolution algorithm.\r\n\r\n## 📃 Motivating Example\r\n\r\nWhen using Deno, you can put up your library + types up on a CDN. However, Deno must have the exact path to the file in order for it to work. Unfortunately it seems that it means that the other declaration files cannot be found because the import path in the declaration file isn't exactly correct. \r\n\r\nUnless I've missed something important about TS / Deno? \r\n\r\n## 💻 Use Cases\r\n\r\nI don't _think_ this would have any effects on the ecosystem, would it? Is there a chance it would maybe even make things slightly faster when looking up types (even for node projects), because the declaration files are pointing directly to the correct file instead of having to go through the resolution algorithm? I'm not sure, I'll defer to you experts. \r\n\r\nThank you ❤️ ","author":{"url":"https://github.com/frehner","@type":"Person","name":"frehner"},"datePublished":"2022-09-03T23:15:12Z","url":"https://github.com/microsoft/TypeScript/issues/50629"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:04ffa161-64cc-c57e-603a-9da7b2b976e7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5AA:240CD1:C67F84:FE14AF:6B00FF1B |
| html-safe-nonce | 0b16e4d242190092c05cdd12dec4d3860ff2ce7c9ff0c7c37942f8485f8e11ea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUFBOjI0MENEMTpDNjdGODQ6RkUxNEFGOjZCMDBGRjFCIiwidmlzaXRvcl9pZCI6IjMyNDI0MzA2OTM3MDMyMjEwMjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d828c1b808751f4d2a008ed5ffedd9d2ae2a776f621b0a6a0f188a34d2371280 |
| hovercard-subject-tag | repository:20929025 |
| 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/microsoft/TypeScript/issues/50629 |
| twitter:image | https://opengraph.githubassets.com/e15f464ad8bbc0886f9cd391ce162cf993e58707e2cc6a0d2b7f905bfb541c3b/microsoft/TypeScript |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e15f464ad8bbc0886f9cd391ce162cf993e58707e2cc6a0d2b7f905bfb541c3b/microsoft/TypeScript |
| og:image:alt | TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Change declaration file import paths from `.js` to `.d.ts` · Issue #50629 · microsoft/TypeScript |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-cache |
| 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