fix(44466): Fixes parsing contextual keyword casts as arrow functions

This commit is contained in:
David Souther
2022-05-09 10:22:22 -07:00
parent 1071240907
commit 3dd9ef43ce
5 changed files with 17 additions and 0 deletions
+4
View File
@@ -4538,6 +4538,10 @@ namespace ts {
// isn't actually allowed, but we want to treat it as a lambda so we can provide
// a good error message.
if (isModifierKind(second) && second !== SyntaxKind.AsyncKeyword && lookAhead(nextTokenIsIdentifier)) {
if (lookAhead(() => nextToken() === SyntaxKind.AsKeyword)) {
// https://github.com/microsoft/TypeScript/issues/44466
return Tristate.False;
}
return Tristate.True;
}
@@ -0,0 +1,8 @@
//// [overrideParenVariable.ts]
let override: any;
export const a = (override as number);
//// [overrideParenVariable.js]
export const a = override;
@@ -0,0 +1,5 @@
//@target: ES5
let readonly: any;
export const a = (readonly as number);