mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
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:
@@ -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.
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user