Title: Synthesized ModuleDeclarations are missing the top level variable declaration in the emit · Issue #17596 · microsoft/TypeScript · GitHub
Open Graph Title: Synthesized ModuleDeclarations are missing the top level variable declaration in the emit · Issue #17596 · microsoft/TypeScript
X Title: Synthesized ModuleDeclarations are missing the top level variable declaration in the emit · Issue #17596 · microsoft/TypeScript
Description: TypeScript Version: 2.4.2 Context Needed by Angular / Tsickle for converting TypeScript types into closure type comments. Our workaround (see transformer_util.ts): copy the ts.Node.Symbol from the original node over to the synthetic node...
Open Graph Description: TypeScript Version: 2.4.2 Context Needed by Angular / Tsickle for converting TypeScript types into closure type comments. Our workaround (see transformer_util.ts): copy the ts.Node.Symbol from the ...
X Description: TypeScript Version: 2.4.2 Context Needed by Angular / Tsickle for converting TypeScript types into closure type comments. Our workaround (see transformer_util.ts): copy the ts.Node.Symbol from the ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17596
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Synthesized ModuleDeclarations are missing the top level variable declaration in the emit","articleBody":"**TypeScript Version:** 2.4.2\r\n\r\n**Context**\r\nNeeded by Angular / Tsickle for converting TypeScript types into closure type comments.\r\n\r\nOur workaround (see [transformer_util.ts](https://github.com/angular/tsickle/blob/master/src/transformer_util.ts)):\r\n- copy the `ts.Node.Symbol` from the original node over to the synthetic node (note that this is an `@internal` field)\r\n\r\n**Code**\r\n\r\nPlunker is [here](https://plnkr.co/edit/Xg9s2gADI7AoEXLJ56CK?p=preview).\r\n\r\ncase.ts\r\n```ts\r\nmodule Reflect {\r\n const x = 1;\r\n}\r\n```\r\n\r\ntransformer.ts:\r\n```\r\nfunction forceSyntheticModuleDeclaration(context: ts.TransformationContext) {\r\n return (sourceFile: ts.SourceFile): ts.SourceFile => {\r\n return visitNode(sourceFile);\r\n\r\n function visitNode\u003cT extends ts.Node>(node: T) {\r\n if (node.kind === ts.SyntaxKind.ModuleBlock) {\r\n const md = node as ts.ModuleBlock;\r\n return ts.updateModuleBlock(md, ts.setTextRange(ts.createNodeArray([...md.statements]));\r\n }\r\n return ts.visitEachChild(node, visitNode, context); \r\n }\r\n };\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nA top level variable statement should be emitted:\r\n```js\r\nvar Reflect;\r\n(function (Reflect) {\r\n var x = 1;\r\n})(Reflect || (Reflect = {}));\r\n```\r\n\r\n**Actual behavior:**\r\nNo top level variable statement is emitted:\r\n```js\r\n(function (Reflect) {\r\n var x = 1;\r\n})(Reflect || (Reflect = {}));\r\n```\r\n\r\n/cc @mprobst @evmar @alexeagle ","author":{"url":"https://github.com/tbosch","@type":"Person","name":"tbosch"},"datePublished":"2017-08-03T21:08:01Z","url":"https://github.com/microsoft/TypeScript/issues/17596"}
| 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:b0e70841-4473-7920-6a00-b621dcea9a0f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BED8:4E0A:428918:54845C:6B00E6A1 |
| html-safe-nonce | dcbb72686a965b2ef4026476145f7c2491917670ad434828a82dd1b3d0dddda1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRUQ4OjRFMEE6NDI4OTE4OjU0ODQ1Qzo2QjAwRTZBMSIsInZpc2l0b3JfaWQiOiIyMDc1NDQ1NzM1Mjk3NDQzNDg5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0bfccd05cfed786de7ed5d92c65546c092740bdee5fe0563517c09c0fe5592d0 |
| hovercard-subject-tag | issue:247835945 |
| 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/17596/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5facdde75544ab8a5841b001764746f287d3bf20c9a5b5eedbce423218dfcd75/microsoft/TypeScript/issues/17596 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5facdde75544ab8a5841b001764746f287d3bf20c9a5b5eedbce423218dfcd75/microsoft/TypeScript/issues/17596 |
| og:image:alt | TypeScript Version: 2.4.2 Context Needed by Angular / Tsickle for converting TypeScript types into closure type comments. Our workaround (see transformer_util.ts): copy the ts.Node.Symbol from the ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tbosch |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width