feat(core): Add "AbstractType<T>" interface (#29295)

This new interface will match classes whether they are abstract or
concrete. Casting as `AbstractType<MyConcrete>` will return a type that
isn't newable. This type will be used to match abstract classes in the
`get()` functions of `Injector` and `TestBed`.
Type isn't used yet so this isn't a breaking change.

Issue #26491

PR Close #29295
This commit is contained in:
Carlos Ortiz García
2019-03-13 17:02:31 -07:00
committed by Jason Aden
parent 60afe88bcc
commit afd4a4ed4d
3 changed files with 15 additions and 1 deletions

View File

@ -22,6 +22,16 @@ export function isType(v: any): v is Type<any> {
return typeof v === 'function';
}
/**
* @description
*
* Represents an abstract class `T`, if applied to a concrete class it would stop being
* instantiatable.
*
* @publicApi
*/
export interface AbstractType<T> extends Function { prototype: T; }
export interface Type<T> extends Function { new (...args: any[]): T; }
export type Mutable<T extends{[x: string]: any}, K extends string> = {