-
Notifications
You must be signed in to change notification settings - Fork 13.4k
add support for Lift Template Literal Restriction #23801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
344d505
6ef797f
3932d20
dbbcdae
c642abe
e92b6bc
9bfb15b
2c973b1
c2580ed
21c91d6
cd46d9f
472223b
789cbed
4fa33a1
2b97fca
78355db
3da97e2
dde0b37
8bf6c64
c4ccddf
3e87998
826802f
7b67e5d
8671a24
6237adf
12a1252
8b65fdc
c4cb21d
36c3bb3
b7f5c77
fd47863
569b35e
45406d4
f8b9bbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ namespace ts { | |
| reScanGreaterToken(): SyntaxKind; | ||
| reScanSlashToken(): SyntaxKind; | ||
| reScanTemplateToken(isTaggedTemplate?: boolean): SyntaxKind; | ||
| reScanTemplateHead(): SyntaxKind; | ||
| reScanTemplateHeadOrNoSubstitutionTemplate(): SyntaxKind; | ||
| scanJsxIdentifier(): SyntaxKind; | ||
| scanJsxAttributeValue(): SyntaxKind; | ||
| reScanJsxToken(): JsxTokenSyntaxKind; | ||
|
|
@@ -424,19 +424,17 @@ namespace ts { | |
| return ch >= CharacterCodes._0 && ch <= CharacterCodes._9; | ||
| } | ||
|
|
||
| /* @internal */ | ||
| export function isOctalDigit(ch: number): boolean { | ||
| return ch >= CharacterCodes._0 && ch <= CharacterCodes._7; | ||
| function isHexDigit(ch: number): boolean { | ||
| return isDigit(ch) || ch >= CharacterCodes.A && ch <= CharacterCodes.F || ch >= CharacterCodes.a && ch <= CharacterCodes.f; | ||
| } | ||
|
|
||
| /* @internal */ | ||
| export function isHexDigit(ch: number): boolean { | ||
| return isDigit(ch) || ch >= CharacterCodes.A && ch <= CharacterCodes.F || ch >= CharacterCodes.a && ch <= CharacterCodes.f; | ||
| function isCodePoint(code: number): boolean { | ||
| return code <= 0x10FFFF; | ||
| } | ||
|
|
||
| /* @internal */ | ||
| export function isCodePoint(code: number): boolean { | ||
| return code <= 0x10FFFF; | ||
| export function isOctalDigit(ch: number): boolean { | ||
| return ch >= CharacterCodes._0 && ch <= CharacterCodes._7; | ||
| } | ||
|
|
||
| export function couldStartTrivia(text: string, pos: number): boolean { | ||
|
|
@@ -852,7 +850,7 @@ namespace ts { | |
| reScanGreaterToken, | ||
| reScanSlashToken, | ||
| reScanTemplateToken, | ||
| reScanTemplateHead, | ||
| reScanTemplateHeadOrNoSubstitutionTemplate, | ||
| scanJsxIdentifier, | ||
| scanJsxAttributeValue, | ||
| reScanJsxToken, | ||
|
|
@@ -1150,7 +1148,7 @@ namespace ts { | |
| // '\01' | ||
| if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { | ||
| pos++; | ||
| tokenFlags |= TokenFlags.NotEscape; | ||
| tokenFlags |= TokenFlags.ContainsInvalidEscape; | ||
| return text.substring(start, pos); | ||
| } | ||
| return "\0"; | ||
|
|
@@ -1174,15 +1172,15 @@ namespace ts { | |
| if (isTaggedTemplate) { | ||
| // '\u' | ||
| if (pos < end && !isHexDigit(text.charCodeAt(pos)) && text.charCodeAt(pos) !== CharacterCodes.openBrace) { | ||
| tokenFlags |= TokenFlags.NotEscape; | ||
| tokenFlags |= TokenFlags.ContainsInvalidEscape; | ||
| return text.substring(start, pos); | ||
| } | ||
|
|
||
| // '\u0' or '\u00' or '\u000' | ||
| for (let i = 0; i < 3; i++) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe call it |
||
| if (pos + i + 1 < end && isHexDigit(text.charCodeAt(pos + i)) && !isHexDigit(text.charCodeAt(pos + i + 1)) && text.charCodeAt(pos + i + 1) !== CharacterCodes.openBrace) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove double space here
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you fold the previous |
||
| pos += i; | ||
| tokenFlags |= TokenFlags.NotEscape; | ||
| tokenFlags |= TokenFlags.ContainsInvalidEscape; | ||
| return text.substring(start, pos); | ||
| } | ||
| } | ||
|
|
@@ -1193,15 +1191,15 @@ namespace ts { | |
|
|
||
| // '\u{' | ||
| if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { | ||
| tokenFlags |= TokenFlags.NotEscape; | ||
| tokenFlags |= TokenFlags.ContainsInvalidEscape; | ||
| return text.substring(start, pos); | ||
| } | ||
|
|
||
| const escapedValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); | ||
| if (isTaggedTemplate) { | ||
| // '\u{Not Code Point' or '\u{CodePoint' | ||
| if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== CharacterCodes.closeBrace) { | ||
| tokenFlags |= TokenFlags.NotEscape; | ||
| tokenFlags |= TokenFlags.ContainsInvalidEscape; | ||
| return text.substring(start, pos); | ||
| } | ||
| } | ||
|
|
@@ -1215,12 +1213,12 @@ namespace ts { | |
| case CharacterCodes.x: | ||
| if (isTaggedTemplate) { | ||
| if (!isHexDigit(text.charCodeAt(pos))) { | ||
| tokenFlags |= TokenFlags.NotEscape; | ||
| tokenFlags |= TokenFlags.ContainsInvalidEscape; | ||
| return text.substring(start, pos); | ||
| } | ||
| else if (!isHexDigit(text.charCodeAt(pos + 1))) { | ||
| pos++; | ||
| tokenFlags |= TokenFlags.NotEscape; | ||
| tokenFlags |= TokenFlags.ContainsInvalidEscape; | ||
| return text.substring(start, pos); | ||
| } | ||
| } | ||
|
|
@@ -1894,7 +1892,7 @@ namespace ts { | |
| return token = scanTemplateAndSetTokenValue(isTaggedTemplate); | ||
| } | ||
|
|
||
| function reScanTemplateHead(): SyntaxKind { | ||
| function reScanTemplateHeadOrNoSubstitutionTemplate(): SyntaxKind { | ||
| pos = tokenPos; | ||
| return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no public API, just make this parameter required.