mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 02:30:15 -06:00
Merge pull request #16736 from DickvdBrink/issue/15208
Also check TypeAlias for unused type parameters
This commit is contained in:
commit
c51c2aecca
@ -19470,6 +19470,9 @@ namespace ts {
|
||||
case SyntaxKind.ConstructorType:
|
||||
checkUnusedTypeParameters(<FunctionLikeDeclaration>node);
|
||||
break;
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
checkUnusedTypeParameters(<TypeAliasDeclaration>node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19547,7 +19550,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkUnusedTypeParameters(node: ClassDeclaration | ClassExpression | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) {
|
||||
function checkUnusedTypeParameters(node: ClassDeclaration | ClassExpression | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration | TypeAliasDeclaration) {
|
||||
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
|
||||
if (node.typeParameters) {
|
||||
// Only report errors on the last declaration for the type parameter container;
|
||||
@ -21252,6 +21255,7 @@ namespace ts {
|
||||
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
|
||||
checkTypeParameters(node.typeParameters);
|
||||
checkSourceElement(node.type);
|
||||
registerForUnusedIdentifiersCheck(node);
|
||||
}
|
||||
|
||||
function computeEnumMemberValues(node: EnumDeclaration) {
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/unusedTypeParameters10.ts(1,12): error TS6133: 'T' is declared but never used.
|
||||
|
||||
|
||||
==== tests/cases/compiler/unusedTypeParameters10.ts (1 errors) ====
|
||||
type Alias<T> = { };
|
||||
~
|
||||
!!! error TS6133: 'T' is declared but never used.
|
||||
type Alias2<T> = { x: T };
|
||||
|
||||
6
tests/baselines/reference/unusedTypeParameters10.js
Normal file
6
tests/baselines/reference/unusedTypeParameters10.js
Normal file
@ -0,0 +1,6 @@
|
||||
//// [unusedTypeParameters10.ts]
|
||||
type Alias<T> = { };
|
||||
type Alias2<T> = { x: T };
|
||||
|
||||
|
||||
//// [unusedTypeParameters10.js]
|
||||
5
tests/cases/compiler/unusedTypeParameters10.ts
Normal file
5
tests/cases/compiler/unusedTypeParameters10.ts
Normal file
@ -0,0 +1,5 @@
|
||||
//@noUnusedLocals:true
|
||||
//@noUnusedParameters:true
|
||||
|
||||
type Alias<T> = { };
|
||||
type Alias2<T> = { x: T };
|
||||
Loading…
x
Reference in New Issue
Block a user