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:
parent
60afe88bcc
commit
afd4a4ed4d
|
@ -29,7 +29,7 @@ export * from './platform_core_providers';
|
|||
export {TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID, MissingTranslationStrategy} from './i18n/tokens';
|
||||
export {ApplicationModule} from './application_module';
|
||||
export {wtfCreateScope, wtfLeave, wtfStartTimeRange, wtfEndTimeRange, WtfScopeFn} from './profile/profile';
|
||||
export {Type} from './interface/type';
|
||||
export {AbstractType, Type} from './interface/type';
|
||||
export {EventEmitter} from './event_emitter';
|
||||
export {ErrorHandler} from './error_handler';
|
||||
export * from './core_private_export';
|
||||
|
|
|
@ -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> = {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
export interface AbstractType<T> extends Function {
|
||||
prototype: T;
|
||||
}
|
||||
|
||||
export interface AfterContentChecked {
|
||||
ngAfterContentChecked(): void;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue