Title: Declaration emit should not inline type definitions · Issue #37151 · microsoft/TypeScript · GitHub
Open Graph Title: Declaration emit should not inline type definitions · Issue #37151 · microsoft/TypeScript
X Title: Declaration emit should not inline type definitions · Issue #37151 · microsoft/TypeScript
Description: TypeScript Version: 3.8.3, 3.8.1, probably others Search Terms: declaration inlining, dts inlining, declaration inline, inline literal, declaration literal Code // parent.ts import { num, obj } from "./child" export const reExportNum = n...
Open Graph Description: TypeScript Version: 3.8.3, 3.8.1, probably others Search Terms: declaration inlining, dts inlining, declaration inline, inline literal, declaration literal Code // parent.ts import { num, obj } fro...
X Description: TypeScript Version: 3.8.3, 3.8.1, probably others Search Terms: declaration inlining, dts inlining, declaration inline, inline literal, declaration literal Code // parent.ts import { num, obj } fro...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/37151
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Declaration emit should not inline type definitions","articleBody":"**TypeScript Version:** 3.8.3, 3.8.1, probably others\r\n\r\n**Search Terms:**\r\n\r\ndeclaration inlining, dts inlining, declaration inline, inline literal, declaration literal\r\n\r\n**Code**\r\n\r\n```ts\r\n// parent.ts\r\nimport { num, obj } from \"./child\"\r\nexport const reExportNum = num;\r\nexport const reExportObj = obj;\r\n```\r\n\r\n```ts\r\n// child.d.ts\r\nexport declare const num: number;\r\nexport declare const obj: { a: 1 };\r\n```\r\n\r\n`tsc index.ts --declaration`\r\n\r\n**Expected behavior:**\r\n\r\nDeclaration emit for `parent.ts` should not inline types.\r\n\r\n```ts\r\n// parent.d.ts\r\nimport { num, obj } from \"./child\"\r\nexport declare const reExportNum: typeof num;\r\nexport declare const reExportObj: typeof obj;\r\n```\r\n\r\n**Actual behavior:**\r\n\r\nToday, declaration emit for `parent.ts` inlines the types **and** eliminates the import of the `child.d.ts` type definition.\r\n\r\n```ts\r\n// parent.d.ts\r\nexport declare const reExportNum: number;\r\nexport declare const reExportObj: {\r\n a: 1;\r\n};\r\n```\r\n\r\nThis is a correctness issue, because consumers of `parent.d.ts` will not get the correct types if the types in `child.d.ts` change.\r\n\r\nIn practice, this is most likely to happen when `parent` and `child` are in separate packages, because they are published independently, i.e. an application uses `parent-package` which uses types from `child-package`. This is exacerbated by the current practice on npm of `parent-package` depending on an unpinned version, using `package.json` dependency syntax `\"child-package\": \"*\"`.\r\n\r\n\r\n> This issue was co-authored with @robpalme","author":{"url":"https://github.com/mheiber","@type":"Person","name":"mheiber"},"datePublished":"2020-03-02T12:45:47Z","url":"https://github.com/microsoft/TypeScript/issues/37151"}
| 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:3015d04a-d275-f613-f1fc-4d7ef5d680e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FBC:1087D4:27D8E44:35460BB:6B01B771 |
| html-safe-nonce | cbdb92ab151ba0c6b586f11b004883146f93a438cb3c8c79c1b323ee50c4e45f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkJDOjEwODdENDoyN0Q4RTQ0OjM1NDYwQkI6NkIwMUI3NzEiLCJ2aXNpdG9yX2lkIjoiNTAxNTgwOTkyMTI4Mzg5NzIwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | df924f5736d7eccc177f781a7480e1ff0bdedb5f3d589db26e2eea17488cae61 |
| hovercard-subject-tag | issue:573950364 |
| 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/37151/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed33574bd6d8146e1b28d8536e45df47d590f5bf8e204cdd1a9044787d795345/microsoft/TypeScript/issues/37151 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed33574bd6d8146e1b28d8536e45df47d590f5bf8e204cdd1a9044787d795345/microsoft/TypeScript/issues/37151 |
| og:image:alt | TypeScript Version: 3.8.3, 3.8.1, probably others Search Terms: declaration inlining, dts inlining, declaration inline, inline literal, declaration literal Code // parent.ts import { num, obj } fro... |
| 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