refactor(ivy): make return value of define(Component|Directive|Pipe|Injector|Injectable) private (#23371) (#23383)
Ivy definition looks something like this: ``` class MyService { static ngInjectableDef = defineInjectable({ … }); } ``` Here the argument to `defineInjectable` is well known public contract which needs to be honored in backward compatible way between versions. The type of the return value of `defineInjectable` on the other hand is private and can change shape drastically between versions without effecting backwards compatibility of libraries publish to NPM. To our users it is effectively an opaque token. For this reson why declare the return value of `defineInjectable` as `never`. PR Close #23383
This commit is contained in:
@ -52,7 +52,7 @@ export class InjectionToken<T> {
|
||||
/** @internal */
|
||||
readonly ngMetadataName = 'InjectionToken';
|
||||
|
||||
readonly ngInjectableDef: InjectableDef<T>|undefined;
|
||||
readonly ngInjectableDef: never|undefined;
|
||||
|
||||
constructor(protected _desc: string, options?: {
|
||||
providedIn?: Type<any>| 'root' | null,
|
||||
@ -71,6 +71,4 @@ export class InjectionToken<T> {
|
||||
toString(): string { return `InjectionToken ${this._desc}`; }
|
||||
}
|
||||
|
||||
export interface InjectableDefToken<T> extends InjectionToken<T> {
|
||||
ngInjectableDef: InjectableDef<T>;
|
||||
}
|
||||
export interface InjectableDefToken<T> extends InjectionToken<T> { ngInjectableDef: never; }
|
||||
|
Reference in New Issue
Block a user