Skip to content

Commit f8c3a55

Browse files
committed
Check type parameters of the type alias declaration
Fixes microsoft#11166
1 parent 45ba67d commit f8c3a55

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17418,6 +17418,7 @@ namespace ts {
1741817418
checkGrammarDecorators(node) || checkGrammarModifiers(node);
1741917419

1742017420
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
17421+
checkTypeParameters(node.typeParameters);
1742117422
checkSourceElement(node.type);
1742217423
}
1742317424

tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/compiler/bar.ts ===
2+
3+
export interface IEventSourcedEntity { }
4+
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(bar.ts, 0, 0))
5+
6+
=== tests/cases/compiler/test.ts ===
7+
import { IEventSourcedEntity } from "./bar";
8+
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8))
9+
10+
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };
11+
>DomainEntityConstructor : Symbol(DomainEntityConstructor, Decl(test.ts, 0, 44))
12+
>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36))
13+
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8))
14+
>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36))
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/compiler/bar.ts ===
2+
3+
export interface IEventSourcedEntity { }
4+
>IEventSourcedEntity : IEventSourcedEntity
5+
6+
=== tests/cases/compiler/test.ts ===
7+
import { IEventSourcedEntity } from "./bar";
8+
>IEventSourcedEntity : any
9+
10+
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };
11+
>DomainEntityConstructor : new () => TEntity
12+
>TEntity : TEntity
13+
>IEventSourcedEntity : IEventSourcedEntity
14+
>TEntity : TEntity
15+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/compiler/typeAliasDeclarationEmit.ts(4,37): error TS2314: Generic type 'callback' requires 1 type argument(s).
2+
3+
4+
==== tests/cases/compiler/typeAliasDeclarationEmit.ts (1 errors) ====
5+
6+
export type callback<T> = () => T;
7+
8+
export type CallbackArray<T extends callback> = () => T;
9+
~~~~~~~~
10+
!!! error TS2314: Generic type 'callback' requires 1 type argument(s).

0 commit comments

Comments
 (0)