diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 80168823b3c4d..081b906cf9829 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -27614,8 +27614,7 @@ namespace ts { } function checkGrammarTypeArguments(node: Node, typeArguments: NodeArray | undefined): boolean { - return checkGrammarForDisallowedTrailingComma(typeArguments) || - checkGrammarForAtLeastOneTypeArgument(node, typeArguments); + return checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarForOmittedArgument(args: NodeArray | undefined): boolean { diff --git a/tests/baselines/reference/allowTrailingCommasInTypeArguments.js b/tests/baselines/reference/allowTrailingCommasInTypeArguments.js new file mode 100644 index 0000000000000..5c3b845db47bd --- /dev/null +++ b/tests/baselines/reference/allowTrailingCommasInTypeArguments.js @@ -0,0 +1,17 @@ +//// [allowTrailingCommasInTypeArguments.ts] +class FooClass { + a: A; + b: B; + c: C; +} + +var a = new FooClass(); + + +//// [allowTrailingCommasInTypeArguments.js] +var FooClass = /** @class */ (function () { + function FooClass() { + } + return FooClass; +}()); +var a = new FooClass(); diff --git a/tests/baselines/reference/allowTrailingCommasInTypeArguments.symbols b/tests/baselines/reference/allowTrailingCommasInTypeArguments.symbols new file mode 100644 index 0000000000000..acc5884057d90 --- /dev/null +++ b/tests/baselines/reference/allowTrailingCommasInTypeArguments.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/allowTrailingCommasInTypeArguments.ts === +class FooClass { +>FooClass : Symbol(FooClass, Decl(allowTrailingCommasInTypeArguments.ts, 0, 0)) +>A : Symbol(A, Decl(allowTrailingCommasInTypeArguments.ts, 0, 15)) +>B : Symbol(B, Decl(allowTrailingCommasInTypeArguments.ts, 0, 17)) +>C : Symbol(C, Decl(allowTrailingCommasInTypeArguments.ts, 0, 20)) + + a: A; +>a : Symbol(FooClass.a, Decl(allowTrailingCommasInTypeArguments.ts, 0, 26)) +>A : Symbol(A, Decl(allowTrailingCommasInTypeArguments.ts, 0, 15)) + + b: B; +>b : Symbol(FooClass.b, Decl(allowTrailingCommasInTypeArguments.ts, 1, 6)) +>B : Symbol(B, Decl(allowTrailingCommasInTypeArguments.ts, 0, 17)) + + c: C; +>c : Symbol(FooClass.c, Decl(allowTrailingCommasInTypeArguments.ts, 2, 6)) +>C : Symbol(C, Decl(allowTrailingCommasInTypeArguments.ts, 0, 20)) +} + +var a = new FooClass(); +>a : Symbol(a, Decl(allowTrailingCommasInTypeArguments.ts, 6, 3)) +>FooClass : Symbol(FooClass, Decl(allowTrailingCommasInTypeArguments.ts, 0, 0)) + diff --git a/tests/baselines/reference/allowTrailingCommasInTypeArguments.types b/tests/baselines/reference/allowTrailingCommasInTypeArguments.types new file mode 100644 index 0000000000000..8b9ecff6ac859 --- /dev/null +++ b/tests/baselines/reference/allowTrailingCommasInTypeArguments.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/allowTrailingCommasInTypeArguments.ts === +class FooClass { +>FooClass : FooClass +>A : A +>B : B +>C : C + + a: A; +>a : A +>A : A + + b: B; +>b : B +>B : B + + c: C; +>c : C +>C : C +} + +var a = new FooClass(); +>a : FooClass +>new FooClass() : FooClass +>FooClass : typeof FooClass + diff --git a/tests/baselines/reference/syntaxErrors.errors.txt b/tests/baselines/reference/syntaxErrors.errors.txt index 25276af3956e5..ebb7ba25acd82 100644 --- a/tests/baselines/reference/syntaxErrors.errors.txt +++ b/tests/baselines/reference/syntaxErrors.errors.txt @@ -1,17 +1,14 @@ tests/cases/conformance/jsdoc/badTypeArguments.js(1,15): error TS1099: Type argument list cannot be empty. -tests/cases/conformance/jsdoc/badTypeArguments.js(2,22): error TS1009: Trailing comma not allowed. ==== tests/cases/conformance/jsdoc/dummyType.d.ts (0 errors) ==== declare class C { t: T } -==== tests/cases/conformance/jsdoc/badTypeArguments.js (2 errors) ==== +==== tests/cases/conformance/jsdoc/badTypeArguments.js (1 errors) ==== /** @param {C.<>} x */ ~~ !!! error TS1099: Type argument list cannot be empty. /** @param {C.} y */ - ~ -!!! error TS1009: Trailing comma not allowed. // @ts-ignore /** @param {C.} skipped */ function f(x, y, skipped) { diff --git a/tests/cases/compiler/allowTrailingCommasInTypeArguments.ts b/tests/cases/compiler/allowTrailingCommasInTypeArguments.ts new file mode 100644 index 0000000000000..691992e84993a --- /dev/null +++ b/tests/cases/compiler/allowTrailingCommasInTypeArguments.ts @@ -0,0 +1,7 @@ +class FooClass { + a: A; + b: B; + c: C; +} + +var a = new FooClass();