Title: Declaration emit reveals paths within dependency that were not referred to in the source file · Issue #38111 · microsoft/TypeScript · GitHub
Open Graph Title: Declaration emit reveals paths within dependency that were not referred to in the source file · Issue #38111 · microsoft/TypeScript
X Title: Declaration emit reveals paths within dependency that were not referred to in the source file · Issue #38111 · microsoft/TypeScript
Description: Context: Generating declaration files Declaration emit reveals paths within dependency that were not referred to in the source file: export declare const instance: import("dependency/internal-types").TheInterface; This is a problem becau...
Open Graph Description: Context: Generating declaration files Declaration emit reveals paths within dependency that were not referred to in the source file: export declare const instance: import("dependency/internal-types...
X Description: Context: Generating declaration files Declaration emit reveals paths within dependency that were not referred to in the source file: export declare const instance: import("dependency/internal-...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/38111
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Declaration emit reveals paths within dependency that were not referred to in the source file","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\nContext:\r\n\r\n- Generating declaration files\r\n\r\nDeclaration emit reveals paths within dependency that were not referred to in the source file:\r\n\r\n```ts\r\nexport declare const instance: import(\"dependency/internal-types\").TheInterface;\r\n```\r\n\r\nThis is a problem because changing paths within a dependency can break a dependent package.\r\n\r\n**TypeScript Version:** 3.9.0-dev.20200212\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\n\r\n- [inline import declaration](https://github.com/microsoft/TypeScript/issues?q=is%3Aissue+is%3Aopen+inline+import+declaration)\r\n- [declaration external relative path](https://github.com/microsoft/TypeScript/issues?q=is%3Aissue+is%3Aopen+declaration+external+relative+path+)\r\n\r\n**Code**\r\n\r\n`node_modules/@types/dependency/entrypoint.d.ts`\r\n```ts\r\nimport { TheInterface } from \"./internal-types\";\r\nexport { TheInterface };\r\nexport declare function getInstance(): TheInterface;\r\n\r\n```\r\n\r\n`node_modules/@types/dependency/internal-types.d.ts`\r\n```ts\r\nexport interface TheInterface {}\r\n```\r\n\r\n`node_modules/@types/dependency/index.d.ts`\r\n```\r\n// empty - doesn't matter for this example\r\n```\r\n\r\n`example.ts`\r\n```ts\r\nimport { getInstance } from \"dependency/entrypoint\";\r\nexport const instance = getInstance();\r\n```\r\n\r\n\r\n`src/app/tsconfig.json`\r\n```json\r\n{\r\n \"compilerOptions\": {\r\n \"declaration\": true,\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n`example.d.ts`\r\n```ts\r\nexport declare const instance: import(\"dependency/entrypoint\").TheInterface;\r\n```\r\n\r\n**Actual behavior:**\r\n\r\n`example.d.ts`\r\n```ts\r\nexport declare const instance: import(\"dependency/internal-types\").TheInterface;\r\n```\r\n\r\nIt seems that part of the solution could involve having the compiler avoid using relative paths in types (`import(\"\u003crelativepath>\").\u003ctypename>`) if the `relativepath` is outside the project.\r\n\r\n**Repro Repo:** https://github.com/mheiber/repro-rel-import-inlining\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n\r\n- Declaration emit should not inline type definitions - #37151\r\n- Proposal: Bundling TS module type definitions - #4433\r\n\r\n**Issue written with the help of**: @rricard, @robpalme and @mkubilayk\r\n","author":{"url":"https://github.com/mheiber","@type":"Person","name":"mheiber"},"datePublished":"2020-04-22T15:22:48Z","url":"https://github.com/microsoft/TypeScript/issues/38111"}
| 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:d599840f-1e8d-a4e2-ec95-44163f79821a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B4CA:16EED3:2AA90BF:365340C:6B01AE9B |
| html-safe-nonce | 423cf7db32e949ffb1f2079bef702fc0d307bec52273a0b99086f1dfb09d993b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNENBOjE2RUVEMzoyQUE5MEJGOjM2NTM0MEM6NkIwMUFFOUIiLCJ2aXNpdG9yX2lkIjoiODMzMDY1NTU2OTk4MzY4MDE1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ca365016900adb49822285329ec98015ddd4df3c8ed5e14e01fc52fff9572132 |
| hovercard-subject-tag | issue:604845307 |
| 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/38111/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b3c185560580e66ed54da26cc84798382424535c975f3f29f4862e1190e411d1/microsoft/TypeScript/issues/38111 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b3c185560580e66ed54da26cc84798382424535c975f3f29f4862e1190e411d1/microsoft/TypeScript/issues/38111 |
| og:image:alt | Context: Generating declaration files Declaration emit reveals paths within dependency that were not referred to in the source file: export declare const instance: import("dependency/internal-types... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mheiber |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width