Check type parameters of the type alias declaration

Fixes #11166
This commit is contained in:
Sheetal Nandi 2016-10-21 16:40:11 -07:00
parent 45ba67d36f
commit f8c3a550ca
5 changed files with 41 additions and 12 deletions

View File

@ -17418,6 +17418,7 @@ namespace ts {
checkGrammarDecorators(node) || checkGrammarModifiers(node);
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
checkTypeParameters(node.typeParameters);
checkSourceElement(node.type);
}

View File

@ -1,12 +0,0 @@
tests/cases/compiler/test.ts(1,10): error TS6133: 'IEventSourcedEntity' is declared but never used.
==== tests/cases/compiler/bar.ts (0 errors) ====
export interface IEventSourcedEntity { }
==== tests/cases/compiler/test.ts (1 errors) ====
import { IEventSourcedEntity } from "./bar";
~~~~~~~~~~~~~~~~~~~
!!! error TS6133: 'IEventSourcedEntity' is declared but never used.
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };

View File

@ -0,0 +1,15 @@
=== tests/cases/compiler/bar.ts ===
export interface IEventSourcedEntity { }
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(bar.ts, 0, 0))
=== tests/cases/compiler/test.ts ===
import { IEventSourcedEntity } from "./bar";
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8))
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };
>DomainEntityConstructor : Symbol(DomainEntityConstructor, Decl(test.ts, 0, 44))
>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36))
>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8))
>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36))

View File

@ -0,0 +1,15 @@
=== tests/cases/compiler/bar.ts ===
export interface IEventSourcedEntity { }
>IEventSourcedEntity : IEventSourcedEntity
=== tests/cases/compiler/test.ts ===
import { IEventSourcedEntity } from "./bar";
>IEventSourcedEntity : any
export type DomainEntityConstructor<TEntity extends IEventSourcedEntity> = { new(): TEntity; };
>DomainEntityConstructor : new () => TEntity
>TEntity : TEntity
>IEventSourcedEntity : IEventSourcedEntity
>TEntity : TEntity

View File

@ -0,0 +1,10 @@
tests/cases/compiler/typeAliasDeclarationEmit.ts(4,37): error TS2314: Generic type 'callback' requires 1 type argument(s).
==== tests/cases/compiler/typeAliasDeclarationEmit.ts (1 errors) ====
export type callback<T> = () => T;
export type CallbackArray<T extends callback> = () => T;
~~~~~~~~
!!! error TS2314: Generic type 'callback' requires 1 type argument(s).