Title: Declaration emit can't utilize exports map information and ends up reporting "this is likely not portable" · Issue #56107 · microsoft/TypeScript · GitHub
Open Graph Title: Declaration emit can't utilize exports map information and ends up reporting "this is likely not portable" · Issue #56107 · microsoft/TypeScript
X Title: Declaration emit can't utilize exports map information and ends up reporting "this is likely not portable" · Issue #56107 · microsoft/TypeScript
Description: 🔎 Search Terms declaration emit nodenext exports map package.json inferred type annotation necessary 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link No response 💻 Code // @strict: true /...
Open Graph Description: 🔎 Search Terms declaration emit nodenext exports map package.json inferred type annotation necessary 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Li...
X Description: 🔎 Search Terms declaration emit nodenext exports map package.json inferred type annotation necessary 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playgroun...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/56107
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Declaration emit can't utilize exports map information and ends up reporting \"this is likely not portable\"","articleBody":"### 🔎 Search Terms\n\ndeclaration emit nodenext exports map package.json inferred type annotation necessary\n\n### 🕗 Version & Regression Information\n\n- This is the behavior in every version I tried\n\n### ⏯ Playground Link\n\n_No response_\n\n### 💻 Code\n\n```ts\r\n// @strict: true\r\n// @declaration: true\r\n// @module: nodenext\r\n// @noImplicitReferences: true\r\n\r\n// @filename: node_modules/effect/dist/declarations/src/Data.d.ts\r\nimport type * as Types from \"./Types.js\";\r\nimport type * as Equal from \"./Equal.js\";\r\n\r\nexport type Data\u003cA extends Readonly\u003cRecord\u003cstring, any>> | ReadonlyArray\u003cany>> =\r\n Readonly\u003cA> & Equal.Equal;\r\n\r\nexport declare const TaggedClass: \u003cKey extends string>(\r\n tag: Key,\r\n) => new \u003cA extends Record\u003cstring, any>>(\r\n args: Types.Equals\u003cOmit\u003cA, keyof Equal.Equal>, {}> extends true\r\n ? void\r\n : Omit\u003cA, keyof Equal.Equal>,\r\n) => Data\u003c\r\n A & {\r\n _tag: Key;\r\n }\r\n>;\r\n\r\n// @filename: node_modules/effect/dist/declarations/src/Equal.d.ts\r\nimport * as Hash from \"./Hash.js\";\r\n\r\nexport declare const symbol: unique symbol;\r\n\r\nexport interface Equal extends Hash.Hash {\r\n [symbol](that: Equal): boolean;\r\n}\r\n\r\n// @filename: node_modules/effect/dist/declarations/src/Hash.d.ts\r\nexport declare const symbol: unique symbol;\r\n\r\nexport interface Hash {\r\n [symbol](): number;\r\n}\r\n\r\n// @filename: node_modules/effect/dist/declarations/src/Types.d.ts\r\nexport type Equals\u003cX, Y> = (\u003cT>() => T extends X ? 1 : 2) extends \u003c\r\n T,\r\n>() => T extends Y ? 1 : 2\r\n ? true\r\n : false;\r\n\r\n// @filename: node_modules/effect/dist/declarations/src/index.d.ts\r\nexport * as Data from \"./Data.js\";\r\n\r\n// @filename: node_modules/effect/dist/effect.cjs.d.ts\r\nexport * from \"./declarations/src/index\";\r\n\r\n// @filename: node_modules/effect/Equal/dist/effect-Equal.cjs.d.ts\r\nexport * from \"../../dist/declarations/src/Equal\";\r\n\r\n// @filename: node_modules/effect/Types/dist/effect-Types.cjs.d.ts\r\nexport * from \"../../dist/declarations/src/Types\";\r\n\r\n// @filename: node_modules/effect/package.json\r\n{\r\n \"name\": \"effect\",\r\n \"exports\": {\r\n \".\": \"./dist/effect.cjs.js\",\r\n \"./Equal\": \"./Equal/dist/effect-Equal.cjs.js\",\r\n \"./Types\": \"./Types/dist/effect-Types.cjs.js\"\r\n }\r\n}\r\n\r\n// @filename: src/index.ts\r\nimport { Data } from \"effect\";\r\nexport class Foo extends Data.TaggedClass(\"Foo\")\u003c{}> {}\r\n```\r\n\n\n### 🙁 Actual behavior\n\n```\r\n==== src/index.ts (2 errors) ====\r\n import { Data } from \"effect\";\r\n export class Foo extends Data.TaggedClass(\"Foo\")\u003c{}> {}\r\n ~~~\r\n!!! error TS2742: The inferred type of 'Foo' cannot be named without a reference to '../node_modules/effect/dist/declarations/src/Equal'. This is likely not portable. A type annotation is necessary.\r\n ~~~\r\n!!! error TS2742: The inferred type of 'Foo' cannot be named without a reference to '../node_modules/effect/dist/declarations/src/Types'. This is likely not portable. A type annotation is necessary.\r\n```\n\n### 🙂 Expected behavior\n\n```ts\r\n//// [index.d.ts]\r\nimport { Data } from \"effect\";\r\ndeclare const Foo_base: new \u003cA extends Record\u003cstring, any>>(args: import(\"effect/Types\").Equals\u003cOmit\u003cA, keyof import(\"effect/Equal\").Equal>, {}> extends true ? void : Omit\u003cA, keyof import(\"effect/Equal\").Equal>) => Data.Data\u003cA & {\r\n _tag: \"Foo\";\r\n}>;\r\nexport declare class Foo extends Foo_base\u003c{}> {\r\n}\r\nexport {};\r\n```\n\n### Additional information about the issue\n\nI think that it would be best if the listed `exports` entries (especially the ones not relying on wildcards but the wildcard support would also be nice) could be automatically loaded by the compiler at some stage of the declaration emit.\r\n\r\nIn this case, this would allow the compiler to discover `effect/Types` and `effect/Equal` and `getAlternativeContainingModules` could return them. \r\n\r\ncc @andrewbranch as `package.json#exports` is your turf 😉 ","author":{"url":"https://github.com/Andarist","@type":"Person","name":"Andarist"},"datePublished":"2023-10-14T22:29:29Z","url":"https://github.com/microsoft/TypeScript/issues/56107"}
| 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:d1ab3e20-bd22-4e56-d4f1-1d0fb97cfcd8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B5C0:C9BDE:FDC0BB:150494D:6B05120B |
| html-safe-nonce | acce5e13423b3bc689a77ab78a3960e561357ed2efc91f063a016553a5c5a686 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUMwOkM5QkRFOkZEQzBCQjoxNTA0OTREOjZCMDUxMjBCIiwidmlzaXRvcl9pZCI6IjQwMzEyMDY4NjY0NTI1NTAxNTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2300af5d1e74e8c2186fe172870fcd8b17152c9c0a6c836881e07416fa01748d |
| hovercard-subject-tag | issue:1943585589 |
| 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/56107/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a433021486b0cc95b60f21c45ab0d4ac8b96589f13fd496ebcea701f8f41f2f/microsoft/TypeScript/issues/56107 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a433021486b0cc95b60f21c45ab0d4ac8b96589f13fd496ebcea701f8f41f2f/microsoft/TypeScript/issues/56107 |
| og:image:alt | 🔎 Search Terms declaration emit nodenext exports map package.json inferred type annotation necessary 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Li... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Andarist |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| 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 | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| 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