Title: Downlevel emit for template strings should use 'void 0' not 'undefined' · Issue #38430 · microsoft/TypeScript · GitHub
Open Graph Title: Downlevel emit for template strings should use 'void 0' not 'undefined' · Issue #38430 · microsoft/TypeScript
X Title: Downlevel emit for template strings should use 'void 0' not 'undefined' · Issue #38430 · microsoft/TypeScript
Description: TypeScript Version: 3.9.x, 4.0.x-dev Search Terms: template string emit Code From ~/tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts: const x = tag`\u{hello} ${ 100 } \xtraordinary ${ 200 } wonderful ${ 300 } \uworl...
Open Graph Description: TypeScript Version: 3.9.x, 4.0.x-dev Search Terms: template string emit Code From ~/tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts: const x = tag`\u{hello} ${ 100 } \xtraord...
X Description: TypeScript Version: 3.9.x, 4.0.x-dev Search Terms: template string emit Code From ~/tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts: const x = tag`\u{hello} ${ 100 } \xtraord...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/38430
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Downlevel emit for template strings should use 'void 0' not 'undefined'","articleBody":"**TypeScript Version:** 3.9.x, 4.0.x-dev\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) --\u003e\r\n**Search Terms:** template string emit\r\n\r\n**Code**\r\n\r\nFrom `~/tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts`:\r\n```ts\r\nconst x = tag`\\u{hello} ${ 100 } \\xtraordinary ${ 200 } wonderful ${ 300 } \\uworld`;\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nES5/ES3 emit:\r\n```js\r\nconst x = tag(__makeTemplateObject([void 0, void 0, \" wonderful \", void 0], [\"\\\\u{hello} \", \" \\\\xtraordinary \", \" wonderful \", \" \\\\uworld\"]), 100, 200, 300);\r\n```\r\n\r\n**Actual behavior:**\r\n\r\nES5/ES3 emit:\r\n```js\r\nconst x = tag(__makeTemplateObject([undefined, undefined, \" wonderful \", undefined], [\"\\\\u{hello} \", \" \\\\xtraordinary \", \" wonderful \", \" \\\\uworld\"]), 100, 200, 300);\r\n```\r\n\r\nIn ES5, `undefined` is an identifier and not a keyword and can be redeclared. In ES3, `undefined` isn't declared. In general we emit `void 0` in these cases.\r\n\r\nThis can be easily addressed by changing `createTemplateCooked` in `~/src/compiler/transformers/taggedTemplate.ts` to return `createVoidZero()` instead of `createIdentifier(\"undefined\")` when a template contains an invalid escape sequence..\r\n\r\n**Playground Link:** [link](https://www.typescriptlang.org/play/index.html?target=0\u0026ts=4.0.0-dev.20200507#code/MYewdgzgLgBAHjAvDKBDA5gAwDoFcDeAFgKYA2pIAvjACT4wCMADEzNdnFAE6ohcAmASzCouAT1r0ATCzYwA7uH7EuAM1ylJMAMyz2uRV1L9MAbgCwAKCA)\r\n\r\n**Related Issues:** https://github.com/microsoft/TypeScript/pull/23801, https://github.com/microsoft/TypeScript/issues/12700","author":{"url":"https://github.com/rbuckton","@type":"Person","name":"rbuckton"},"datePublished":"2020-05-08T21:49:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/38430/TypeScript/issues/38430"}
| 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:ce77326e-2f56-f514-6bb4-9eb8092f0ff1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 83C2:2017FC:15C7944:1F1EFA0:6A634F0F |
| html-safe-nonce | 76f614558e9c71447491e3095153b0f869f86a57d701f9df059a5de2cf5eafa4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0MyOjIwMTdGQzoxNUM3OTQ0OjFGMUVGQTA6NkE2MzRGMEYiLCJ2aXNpdG9yX2lkIjoiMjk1MTIwNTI2NTA0Njk4MjQxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cd1cba08d81b3cb95939706b0181e94fdbce9afd2e1960453ab77e2c28b8bbd8 |
| hovercard-subject-tag | issue:615004993 |
| 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/38430/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e4e041a99b0f2f19069e7adb4e0c8e8537d8bc93ad29e79ec92201b4c5a760b5/microsoft/TypeScript/issues/38430 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e4e041a99b0f2f19069e7adb4e0c8e8537d8bc93ad29e79ec92201b4c5a760b5/microsoft/TypeScript/issues/38430 |
| og:image:alt | TypeScript Version: 3.9.x, 4.0.x-dev Search Terms: template string emit Code From ~/tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts: const x = tag`\u{hello} ${ 100 } \xtraord... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rbuckton |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94 |
| 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 | 990295d92a4cc7b63fbbd83a046217cd7d77d49c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width