Title: [TS 5.4.0-beta] .d.ts emit adding an inline type import instead of utilising existing import · Issue #57415 · microsoft/TypeScript · GitHub
Open Graph Title: [TS 5.4.0-beta] .d.ts emit adding an inline type import instead of utilising existing import · Issue #57415 · microsoft/TypeScript
X Title: [TS 5.4.0-beta] .d.ts emit adding an inline type import instead of utilising existing import · Issue #57415 · microsoft/TypeScript
Description: 🔎 Search Terms declaration emit inline type import resolution 🕗 Version & Regression Information This changed between versions 5.3.3 and 5.4.0-beta This changed in PR #56857 ⏯ Playground Link https://www.typescriptlang.org/dev/bug-workbe...
Open Graph Description: 🔎 Search Terms declaration emit inline type import resolution 🕗 Version & Regression Information This changed between versions 5.3.3 and 5.4.0-beta This changed in PR #56857 ⏯ Playground Link https...
X Description: 🔎 Search Terms declaration emit inline type import resolution 🕗 Version & Regression Information This changed between versions 5.3.3 and 5.4.0-beta This changed in PR #56857 ⏯ Playground Link h...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/57415
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[TS 5.4.0-beta] .d.ts emit adding an inline type import instead of utilising existing import","articleBody":"### 🔎 Search Terms\n\ndeclaration emit inline type import resolution\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 5.3.3 and 5.4.0-beta\r\n- This changed in PR #56857\r\n\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/dev/bug-workbench/?emitDeclarationOnly=true&baseUrl=true&ts=5.4.0-beta#code/PTAEAEBMFMGMBsCGAnRAXAlgewHYCgQIBnACywHcBRAWwzQLHFIprrWkgDEN5oAuUIgAOQ4DkQA3DAHN0WZMHIZI06GgC0AM0Sw08gJ4A6SIbRE8DCJp7Rx1fqHgYARsAw4YAD2OnzGakLyaKAAVIJEoAAi0NoArvBolJ6ByMGayFjUoABEhm447Mji8MAwcQkA+tDJQUTZANx41SnBAN5RMYjxiTWp4aBlXQmgAL6NzUGh-QBCiETQAOrukBSg6Zk5ee6FxYrLFETAznPQSh4UPmYNFoTg1rx2Dk6u29BFiCWD3VW9ZpfmEz67S+wzmoFm8yW53IozWGSyuT20MOx3mZxW5GuljuNkeAme+R2HyRGJRJ3RFxMZjwr2Q2lg0HBJyhGNArRGTV+oFp9MZEMW+3IAGFcEQ0MhYrp5GyOTAEChGbBRcF+SyKAJVYKRTgxRKpchxlyQSrmYLGjdGPdbIh7PiXOpYph4IdSArIOo0PohNBDkoVGp1EqcNZpP8aQFJp7vaAAKoASThG1yeUMeQJy2q10BwR5OkZS39aE4Oj0yH0bLwoCr3J1aEQBQwcmQAAohAqCmryAJ44ZNdCAJQCCRYZSNDnYq14wQiMSSGRNvaFrQlgy+cMtNkF1RFldlkaJhGp4BH54Op0ukhuj1en2L7eB3AhrFypDIRXKmti+uYJsCLdqYt9X0ABtABydwvwbJtQIAXXNQgAFZDAAZgECoKiIfQChINQMFgH4WgqZ4KgARl7U1oWMTpuksJCABYBH8Fpm2TY80xcQk3l2Y0CNqbJ+3IyFBU5DdjVAAB5ZwACs4DQQx0mgaAAC9oGbVpK2rCC6yg0s8BGftzSYyMbymMF0Mw7DcPw7MiJcUiD02FN2JeDxM0aIA\n\n### 💻 Code\n\n```ts repro\r\n// @declaration\r\n// @showEmit\r\n// @showEmittedFile: app/navigator/widget-factory.d.ts\r\n\r\n// @filename: lib/index.d.ts\r\nimport * as DefaultExport from \"./internal/default_exports\";\r\nexport { DefaultExport as default };\r\nexport * as BaseWindow from \"./internal/windows/basewindow.d.ts\";\r\n\r\n// @filename: lib/internal/default_exports.d.ts\r\nexport { default as BaseWindow } from \"./windows/basewindow\";\r\n\r\n// @filename: lib/internal/windows/basewindow.d.ts\r\ninterface BaseWindow {}\r\nexport interface BaseWindowConstructor {}\r\ndeclare const BaseWindow: BaseWindowConstructor;\r\nexport default BaseWindow;\r\n\r\n\r\n// @filename: lib-utils/shared-types/widget-config.d.ts\r\nimport type UI from \"../../lib/index\";\r\nexport interface WidgetFactory {\r\n instantiator(parentWindow: UI.BaseWindow): void;\r\n}\r\n\r\n// @filename: app/navigator/widget-factory.ts\r\nimport {WidgetFactory} from \"../../lib-utils/shared-types/widget-config\";\r\n\r\ndeclare const instantiator: WidgetFactory['instantiator'];\r\n\r\n// 5.3: __synthetic_export_lib_1.BaseWindow.default\r\n// 5.4: import(\"../../lib/internal/default_exports\").BaseWindow\r\nexport default Object.freeze({\r\n instantiator\r\n});\r\n\r\n// Our tools inject this before we pass the file to TS.\r\nimport type * as __synthetic_export_lib_1 from \"../../lib/index\";\r\n```\r\n\r\n\n\n### 🙁 Actual behavior\n\n```typescript\r\n// app/navigator/widget-factory.d.ts\r\ndeclare const _default: Readonly\u003c{\r\n instantiator: (parentWindow: import(\"../../lib/internal/default_exports\").BaseWindow) => void;\r\n}>;\r\nexport default _default;\r\nimport type * as __synthetic_export_lib_1 from \"../../lib/index\";\r\n```\n\n### 🙂 Expected behavior\n\n```typescript\r\n// app/navigator/widget-factory.d.ts\r\ndeclare const _default: Readonly\u003c{\r\n instantiator: (parentWindow: __synthetic_export_lib_1.BaseWindow.default) => void;\r\n}>;\r\nexport default _default;\r\nimport type * as __synthetic_export_lib_1 from \"../../lib/index\";\r\n```\n\n### Additional information about the issue\n\nMore background in previous conversation around this: #38111 and this public blog post: https://www.bloomberg.com/company/stories/10-insights-adopting-typescript-at-scale/\r\n\r\nThe JavaScript runtime we are using TypeScript on is not based on npm style packages (no `node_modules` resolution or `package.json` manifest). For the `.d.ts` that we publish to be able to work consistently across different versions it's important that the inter-package import paths only resolve to the 'public' files and not internal implementation `.d.ts` files.\r\n\r\nTo encourage TypeScript to pick these safer paths when emitting `.d.ts` we add unused imports to the bottom of each file before passing them to the TS compiler.\r\n\r\nIn general this is still working in 5.4.0-beta, however during our testing at least 8 packages's `.d.ts` emit regressed with the beta. The playground above re-creates one of these. \r\n\r\n","author":{"url":"https://github.com/acutmore","@type":"Person","name":"acutmore"},"datePublished":"2024-02-15T15:16:20Z","url":"https://github.com/microsoft/TypeScript/issues/57415"}
| 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:025fcaab-e788-e174-7592-8a7680239c14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA36:31E3E4:DC5A9B:11F6897:6B04E596 |
| html-safe-nonce | d25595b8aeece5b6808c7f7f099f053124570f8c9225bb56105cf31c1a011cc4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTM2OjMxRTNFNDpEQzVBOUI6MTFGNjg5Nzo2QjA0RTU5NiIsInZpc2l0b3JfaWQiOiIyOTA4NDY1Mzc1NDgwMTc4MDcwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 03bd07ced2fa993c5b37a71e6fa5331a3b30bd8ceca8258503d83df28b054d5c |
| hovercard-subject-tag | issue:2136792472 |
| 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/57415/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6225df5f2f1d1750d4b07fd77f30b0fa2a945ec92aeba21867ce28414efb0271/microsoft/TypeScript/issues/57415 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6225df5f2f1d1750d4b07fd77f30b0fa2a945ec92aeba21867ce28414efb0271/microsoft/TypeScript/issues/57415 |
| og:image:alt | 🔎 Search Terms declaration emit inline type import resolution 🕗 Version & Regression Information This changed between versions 5.3.3 and 5.4.0-beta This changed in PR #56857 ⏯ Playground Link https... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | acutmore |
| hostname | github.com |
| expected-hostname | github.com |
| None | 970f03f35f02bb123d2b6f1884601d89a570dc02e5ef9612b1b6ca5c033b1796 |
| 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 | ebcec4199c8521b643c068ef118a1ba9a43b678a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width