Title: Lift Template Literal Restriction on Backslashes · Issue #12700 · microsoft/TypeScript · GitHub
Open Graph Title: Lift Template Literal Restriction on Backslashes · Issue #12700 · microsoft/TypeScript
X Title: Lift Template Literal Restriction on Backslashes · Issue #12700 · microsoft/TypeScript
Description: Overview Everyone loves LATEX so ESNext will likely allow tagged template strings to contain backslashes on any sequence - even ones that look like they might contain an invalid Unicode escapes. In other words, something like let x = tag...
Open Graph Description: Overview Everyone loves LATEX so ESNext will likely allow tagged template strings to contain backslashes on any sequence - even ones that look like they might contain an invalid Unicode escapes. In...
X Description: Overview Everyone loves LATEX so ESNext will likely allow tagged template strings to contain backslashes on any sequence - even ones that look like they might contain an invalid Unicode escapes. In...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/12700
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Lift Template Literal Restriction on Backslashes","articleBody":"# Overview\r\n\r\nEveryone loves L\u003csup\u003eA\u003c/sup\u003eT\u003csub\u003eE\u003c/sub\u003eX so ESNext will likely allow tagged template strings to contain backslashes on any sequence - even ones that look like they might contain an invalid Unicode escapes.\r\n\r\nIn other words, something like\r\n\r\n```ts\r\nlet x = tag `\\u{wat}`;\r\n```\r\n\r\nis now valid, whereas previously it would be considered an error.\r\n\r\nReference: https://tc39.github.io/proposal-template-literal-revision/\r\n\r\nAs of this writing, the linked proposal is at Stage 3.\r\n\r\n# Notes\r\n\r\n1. This restriction lift doesn't apply to *untagged* template strings. For example:\r\n\r\n ```ts\r\n // All of these are still invalid.\r\n let bad = `bad escape sequence: \\unicode`;\r\n let bracingOurselves = `\\u{shouldntDoThis}`;\r\n let theWorst = `\\xtremely bad`;\r\n ```\r\n\r\n2. Because there is no appropriate representation for a \"cooked\" string that contains one of these escapes, the returned value at a position on the top-level array will be `undefined`, but the raw representation will be available. For example:\r\n\r\n ```ts\r\n function tag(strs) {\r\n console.log(strs[0] === undefined);\r\n console.log(strs.raw[0] === \"\\\\unicode and \\\\u{55}\");\r\n }\r\n // Prints 'true' twice.\r\n tag`\\unicode and \\u{55}`\r\n\r\n# Proposed Emit\r\n\r\nInput:\r\n\r\n```ts\r\nlet x = tag `\\u{hello} ${ 100 } \\xtraordinary ${ 200 } wonderful ${ 300 } \\uworld`;\r\n```\r\n\r\nOutput:\r\n\r\n```js\r\nvar x = (\r\n _a = [undefined, undefined, \" wonderful \", undefined],\r\n _a.raw = [\"\\\\u{hello} \", \" \\\\xtraordinary \", \" wonderful \", \" \\\\uworld\"],\r\n tag(_a, 100, 200, 300)\r\n);\r\n```","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2016-12-06T23:56:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/12700/TypeScript/issues/12700"}
| 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:7f32647e-de5f-b2eb-5839-7ac1ac753984 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C28:13B657:896102:BC099C:6A627DB9 |
| html-safe-nonce | 2c945db9fbd43b2820dc72210a28e398a8f0d1a8b86d75edf42c7a1385fff387 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzI4OjEzQjY1Nzo4OTYxMDI6QkMwOTlDOjZBNjI3REI5IiwidmlzaXRvcl9pZCI6IjI4MjQ5OTEyOTUxMDc4MzI5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0912fe15786295dc82a1d2fd703f501242cddacc7d495c6fde0f040fefe90524 |
| hovercard-subject-tag | issue:193920521 |
| 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/12700/issue_layout |
| twitter:image | https://opengraph.githubassets.com/71919674f4429b83935246fb7d8f014761379cbf7176a5be5a560eca3d84580f/microsoft/TypeScript/issues/12700 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/71919674f4429b83935246fb7d8f014761379cbf7176a5be5a560eca3d84580f/microsoft/TypeScript/issues/12700 |
| og:image:alt | Overview Everyone loves LATEX so ESNext will likely allow tagged template strings to contain backslashes on any sequence - even ones that look like they might contain an invalid Unicode escapes. In... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54d77223ecd96549586d00f1e91ee7d05feebf27ea430279a9c4ba4b7de1a93c |
| 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 | 4d79f1b99472a521fc5fb66e9fdc3ce742937dff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width