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 HauandKlaus Meinhardt authored and Ryan Cavanaugh committed 2019-08-15 15:49:50 -07:00
1 parent 334b8590e9
commit dcb763f624
5 files changed
+24 -1

No files matched your search

+2 -1
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;
}