Repository navigation
\u in String.rawΒ #42887
Description
Activity
DanielRosenwasser commented
on Feb 20, 2021 MemberMore actionsWenlu Wang (@Kingwl) you might be interested in this one.
- addedBugA bug in TypeScriptA bug in TypeScriptGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do this
on Feb 20, 2021 Itβs not just
String.raw, this applies to all tagged template literals, whereΒ theΒ topβlevelTemplateStringArraycontainsΒundefinedforΒ anΒ unknownΒ escape, soΒ thisΒ should alsoΒ updateTemplateStringsArray:const taggedTemplate = (template: TemplateStringsArray, ...substitutions: unknown[]) => { console.log(template, substitutions); } // Logs: // [ // undefined, "bar", undefined, // raw: [ "foo\\uvar", "bar", "baz\\u" ] // ] // [ 123, 456 ] taggedTemplate`foo\uvar${123}bar${456}baz\u`;
Also, this doesnβt occur when theΒ
\uΒ follows aΒ substitution.- addedHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-repros
on Feb 20, 2021 Itβs not just String.raw, this applies to all tagged template literals
Sorry I'm not 100% sure what your means.
But seems the runtime behavior is as expected.The current problem is falsely alarm.
Here's some context:
- add support for Lift Template Literal RestrictionΒ #23801
- https://tc39.github.io/proposal-template-literal-revision/
And I have found an PR who try to fix a part of the alarm: #41030
TheΒ definition ofΒ
TemplateStringArrayshouldΒ includeundefinedinΒ theΒ topβlevel indexΒ signature, whichΒ should beΒ fixed alongsideΒ this toΒ correctlyΒ describe theΒ runtimeΒ behaviour asΒ ofΒ tc39/ecma262@138c9ef.Ahhhh Okay. Got the point. Thanks.
elibarzilay commented
on Jun 3, 2021 ContributorMore actionsI think that dealing with octal escapes in all strings #396 should be done before dealing with tagged templates as an exception...
typescript-bot commented
on Apr 14, 2022 ContributorMore actionsπ Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of this repro running against the nightly TypeScript.
Comment by ExE Boss (@ExE-Boss)
β Failed: -
Hexadecimal digit expected.
Historical Information
Version Reproduction Outputs 4.2.2, 4.3.2, 4.4.2, 4.5.2, 4.6.2 β Failed: -
Hexadecimal digit expected.
bentongxyz commented
on Apr 28, 2022 ContributorMore actionsHi, is this issue being worked on? I would like to look into this as a first issue.
The definition of TemplateStringArray should include undefined in the topβlevel index signature,
I'm afraid such a change will break existing code.
undefinedis there only if a part of string template contains invalid escape characters, and this information is available in compile-time. I'd suggest replacingTemplateStringsArraywith areadonlytuple ofstrings andundefineds, intersected with{raw: ...}. of equal-sized tuple ofstrings. This type should be backwards compatible.- locked as resolved and limited conversation to collaborators
on Oct 21, 2025

Bug Report
π Search Terms
String.raw
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Error reported:
error TS1125: Hexadecimal digit expected.π Expected behavior
Complete transpile