`\u` in String.raw
Bug Report
🔎 Search Terms
String.raw
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about String.raw
⏯ Playground Link
Playground link with relevant code
💻 Code
String.raw`adc\def\ghi\jkl\mno\pqr\st\uvw\xyz`
🙁 Actual behavior
Error reported: error TS1125: Hexadecimal digit expected.
🙂 Expected behavior
Complete transpile
@Kingwl you might be interested in this one.
It’s not just String.raw, this applies to all tagged template literals, where the top‑level TemplateStringArray contains undefined for an unknown escape, so this should also update TemplateStringsArray:
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.
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:
- https://github.com/microsoft/TypeScript/pull/23801
- https://tc39.github.io/proposal-template-literal-revision/
And I have found an PR who try to fix a part of the alarm: https://github.com/microsoft/TypeScript/pull/41030
The definition of TemplateStringArray should include undefined in the top‑level index signature, which should be fixed alongside this to correctly describe the runtime behaviour as of https://github.com/tc39/ecma262/commit/138c9efc5460c22e175007ba2608b2c4238e11ef.
Ahhhh Okay. Got the point. Thanks.
I think that dealing with octal escapes in all strings #396 should be done before dealing with tagged templates as an exception...
:wave: 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
:x: Failed: -
Hexadecimal digit expected.
Historical Information
| Version | Reproduction Outputs |
|---|---|
| 4.2.2, 4.3.2, 4.4.2, 4.5.2, 4.6.2 |
:x: Failed: -
|
Hi, is this issue being worked on? I would like to look into this as a first issue.
Almost created a duplicate to this issue.
@ExE-Boss
The definition of TemplateStringArray should include undefined in the top‑level index signature,
I'm afraid such a change will break existing code. undefined is there only if a part of string template contains invalid escape characters, and this information is available in compile-time. I'd suggest replacing TemplateStringsArray with a readonly tuple of strings and undefineds, intersected with {raw: ...}. of equal-sized tuple of strings. This type should be backwards compatible.