fix(49704): Code folding not working in file with simple syntax error (#49743)

* fix(49704): parse type arguments in super call expression

* omit duplicate errors
This commit is contained in:
Oleksandr T
2022-07-19 16:26:56 -07:00
committed by GitHub
parent 7f3ca9f8f7
commit f6ac10958f
7 changed files with 19 additions and 3 deletions
+1 -1
View File
@@ -30780,7 +30780,7 @@ namespace ts {
let typeArguments: NodeArray<TypeNode> | undefined;
if (!isDecorator) {
if (!isDecorator && !isSuperCall(node)) {
typeArguments = (node as CallExpression).typeArguments;
// We already perform checking on the type arguments on the class declaration itself.
+4 -1
View File
@@ -5285,12 +5285,15 @@ namespace ts {
function parseSuperExpression(): MemberExpression {
const pos = getNodePos();
const expression = parseTokenNode<PrimaryExpression>();
let expression = parseTokenNode<MemberExpression>();
if (token() === SyntaxKind.LessThanToken) {
const startPos = getNodePos();
const typeArguments = tryParse(parseTypeArgumentsInExpression);
if (typeArguments !== undefined) {
parseErrorAt(startPos, getNodePos(), Diagnostics.super_may_not_use_type_arguments);
if (!isTemplateStartOfTaggedTemplate()) {
expression = factory.createExpressionWithTypeArguments(expression, typeArguments);
}
}
}
@@ -6,5 +6,6 @@ class C {
>M : Symbol(C.M, Decl(parserSuperExpression2.ts, 0, 9))
super<T>(0);
>T : Symbol(T)
}
}
@@ -12,5 +12,6 @@ class D<T> extends C {
constructor() {
super<T>();
>super : Symbol(C, Decl(superWithTypeArgument.ts, 0, 0))
>T : Symbol(T, Decl(superWithTypeArgument.ts, 4, 8))
}
}
@@ -19,6 +19,7 @@ class D<T> extends C<T> {
super<T>(x);
>super : Symbol(C, Decl(superWithTypeArgument2.ts, 0, 0))
>T : Symbol(T, Decl(superWithTypeArgument2.ts, 4, 8))
>x : Symbol(x, Decl(superWithTypeArgument2.ts, 5, 16))
}
}
@@ -23,6 +23,7 @@ class D<T> extends C<T> {
constructor() {
super<T>();
>super : Symbol(C, Decl(superWithTypeArgument3.ts, 0, 0))
>T : Symbol(T, Decl(superWithTypeArgument3.ts, 5, 8))
}
bar() {
>bar : Symbol(D.bar, Decl(superWithTypeArgument3.ts, 8, 5))
+10 -1
View File
@@ -114,6 +114,15 @@
//// 2
//// ]|]
////)|];
////
////class C<T>[| {
//// foo: T;
////}|]
////
////class D<T> extends C<T>[| {
//// constructor(x)[| {
//// super<T>(x);
//// }|]
////}|]
verify.outliningSpansInCurrentFile(test.ranges(), "code");