Skip to content
Permalink
Browse files

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
  • Loading branch information...
Goodwine authored and jasonaden committed Mar 14, 2019
1 parent 60afe88 commit afd4a4ed4d9b8baec64141569ff249bd7df92f54
Showing with 15 additions and 1 deletion.
  1. +1 −1 packages/core/src/core.ts
  2. +10 −0 packages/core/src/interface/type.ts
  3. +4 −0 tools/public_api_guard/core/core.d.ts
@@ -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;
}

0 comments on commit afd4a4e

Please sign in to comment.
You can’t perform that action at this time.