Title: Syntax error in emitted declaration's generic arguments · Issue #42079 · microsoft/TypeScript · GitHub
Open Graph Title: Syntax error in emitted declaration's generic arguments · Issue #42079 · microsoft/TypeScript
X Title: Syntax error in emitted declaration's generic arguments · Issue #42079 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms syntax error declaration emit generics "Cannot find name" ts2304 🕗 Version & Regression Information This is syntactically incorrect output from tsc It is not a regression This is the behavior in every version I ...
Open Graph Description: Bug Report 🔎 Search Terms syntax error declaration emit generics "Cannot find name" ts2304 🕗 Version & Regression Information This is syntactically incorrect output from tsc It is not a regression ...
X Description: Bug Report 🔎 Search Terms syntax error declaration emit generics "Cannot find name" ts2304 🕗 Version & Regression Information This is syntactically incorrect output from tsc It is not...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/42079
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Syntax error in emitted declaration's generic arguments","articleBody":"# Bug Report\r\n\r\n### 🔎 Search Terms\r\n\r\nsyntax error declaration emit generics \"Cannot find name\" ts2304\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This is syntactically incorrect output from tsc\r\n- It is not a regression\r\n- This is the behavior in every version I tried (3.3 - 4.2.0-dev.20201222)\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground link with relevant code](https://www.typescriptlang.org/dev/bug-workbench/?ts=4.2.0-dev.20201222#code/PTAEAEBMFMGMBsCGAnRAXAlgewHYCgQJF54sB3AKQGcAuUAM2KujwLHHo3mh0QFtodPogw4AdGip40ATwAO0UAHVUcgDwBBAHygAvKADeeUCdA5oVNHQ14AvgG48otNGSNYigArJoANx5oAJI48KKiAObBACJwSKiYuACifBhohnZ40AAecljIabIKoJ4ArgBGobAqiOoAGgA0oACaeoa2OvrV6k06AGTFPv44QSFhOJE4MQgo6Ng4yamO2bn5DCU4sAk4DDhqACo6ABQo4XR7AJSgdKUVGFWq+zpGpqA+aCXI2wZmFlagJ6BbBlYLhLD9LNBIK16DhDt96FgsHQAIy2c72UyEADKMmGiCyoESyGQeVAolAMGm8TmoGgKTSAAtXCxlnk0jBGCV4GlzBDII4gA)\r\n\r\n**Important:** The playground itself has a rendering bug in the display of the declaration. It still looks invalid. But it's invalid in another way in the truthful output. I paste the truthful output below.\r\n\r\n### 💻 Code\r\n\r\n```ts\r\n// @declaration\r\ntype Wrap\u003cA> = {\r\n nest: A\r\n};\r\ninterface PreventInliningInDeclarationEmit {\r\n}\r\nexport type PublicWrap\u003cX, Y = {}> = Wrap\u003cY> & PreventInliningInDeclarationEmit;\r\nexport function fn\u003cT> (arg: T) : PublicWrap\u003cT> {\r\n return { nest: arg }\r\n}\r\nconst nested = fn({ foo: 1}); // Syntax Error in declaration emit here\r\nexport default nested;\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nEmitted declaration has syntax error. `Cannot find name 'T'. (ts2304)`\r\n\r\n```ts\r\ndeclare type Wrap\u003cA> = {\r\n nest: A;\r\n};\r\ninterface PreventInliningInDeclarationEmit {\r\n}\r\nexport declare type PublicWrap\u003cX, Y = {}> = Wrap\u003cY> & PreventInliningInDeclarationEmit;\r\nexport declare function fn\u003cT>(arg: T): PublicWrap\u003cT>;\r\ndeclare const nested: PublicWrap\u003cT, {}>;\r\nexport default nested;\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\nA valid declaration.\r\n\r\n```ts\r\ndeclare type Wrap\u003cA> = {\r\n nest: A;\r\n};\r\ninterface PreventInliningInDeclarationEmit {\r\n}\r\nexport declare type PublicWrap\u003cX, Y = {}> = Wrap\u003cY> & PreventInliningInDeclarationEmit;\r\nexport declare function fn\u003cT>(arg: T): PublicWrap\u003cT>;\r\ndeclare const nested: PublicWrap\u003c{\r\n foo: number;\r\n}>;\r\nexport default nested;\r\n```\r\n\r\n","author":{"url":"https://github.com/robpalme","@type":"Person","name":"robpalme"},"datePublished":"2020-12-22T18:38:04Z","url":"https://github.com/microsoft/TypeScript/issues/42079"}
| 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:6c8a45eb-9004-4418-01b0-3c2f77caff09 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 83D6:DB09F:29DBCB9:356C6B2:6B01AFBF |
| html-safe-nonce | 06cdca181d9e89468b70af26bf0f3e8aaf294e50542fdff118f4e38e27a87254 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0Q2OkRCMDlGOjI5REJDQjk6MzU2QzZCMjo2QjAxQUZCRiIsInZpc2l0b3JfaWQiOiI1Njg4ODc0ODUxODMwNDQzOTY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a43750d552e1fc5b7a09e026bf936e4812d587799c725255318fa9a98b869c5b |
| hovercard-subject-tag | issue:773162114 |
| 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/42079/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8c41dec594682036aa119a17b3267fa98881229429a0e6eee90cb0ef2007fdcd/microsoft/TypeScript/issues/42079 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8c41dec594682036aa119a17b3267fa98881229429a0e6eee90cb0ef2007fdcd/microsoft/TypeScript/issues/42079 |
| og:image:alt | Bug Report 🔎 Search Terms syntax error declaration emit generics "Cannot find name" ts2304 🕗 Version & Regression Information This is syntactically incorrect output from tsc It is not a regression ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | robpalme |
| 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