Report error when using generic class in js file (#31723)

* Report error when using generic class in js file

* Replace "ClassDeclaration | ClassExpression" to ClassLikeDeclaration

Co-Authored-By: Klaus Meinhardt <klaus.meinhardt1@gmail.com>

* add noEmit:true
This commit is contained in:
Tan Li Hau
2019-08-16 06:49:50 +08:00
committed by Ryan Cavanaugh
parent 334b8590e9
commit dcb763f624
5 changed files with 24 additions and 1 deletions

View File

@@ -1833,6 +1833,7 @@ namespace ts {
switch (parent.kind) {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.Constructor:
@@ -1842,7 +1843,7 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ArrowFunction:
// Check type parameters
if (nodes === (<ClassDeclaration | FunctionLikeDeclaration>parent).typeParameters) {
if (nodes === (<ClassLikeDeclaration | FunctionLikeDeclaration>parent).typeParameters) {
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
return;
}