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:
34
tools/public_api_guard/core/core.d.ts
vendored
34
tools/public_api_guard/core/core.d.ts
vendored
@ -244,14 +244,14 @@ export declare class DefaultIterableDiffer<V> implements IterableDiffer<V>, Iter
|
||||
export declare function defineInjectable<T>(opts: {
|
||||
providedIn?: Type<any> | 'root' | 'any' | null;
|
||||
factory: () => T;
|
||||
}): InjectableDef<T>;
|
||||
}): never;
|
||||
|
||||
/** @experimental */
|
||||
export declare function defineInjector(options: {
|
||||
factory: () => any;
|
||||
providers?: any[];
|
||||
imports?: any[];
|
||||
}): InjectorDef<any>;
|
||||
}): never;
|
||||
|
||||
/** @experimental */
|
||||
export declare function destroyPlatform(): void;
|
||||
@ -354,19 +354,12 @@ export interface InjectableDecorator {
|
||||
} & InjectableProvider): Injectable;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export interface InjectableDef<T> {
|
||||
factory: () => T;
|
||||
providedIn: InjectorType<any> | 'root' | 'any' | null;
|
||||
value: T | undefined;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare type InjectableProvider = ValueSansProvider | ExistingSansProvider | StaticClassSansProvider | ConstructorSansProvider | FactorySansProvider | ClassSansProvider;
|
||||
|
||||
/** @experimental */
|
||||
export interface InjectableType<T> extends Type<T> {
|
||||
ngInjectableDef: InjectableDef<T>;
|
||||
ngInjectableDef: never;
|
||||
}
|
||||
|
||||
export interface InjectDecorator {
|
||||
@ -384,7 +377,7 @@ export declare const enum InjectFlags {
|
||||
|
||||
export declare class InjectionToken<T> {
|
||||
protected _desc: string;
|
||||
readonly ngInjectableDef: InjectableDef<T> | undefined;
|
||||
readonly ngInjectableDef: never | undefined;
|
||||
constructor(_desc: string, options?: {
|
||||
providedIn?: Type<any> | 'root' | null;
|
||||
factory: () => T;
|
||||
@ -397,7 +390,7 @@ export declare abstract class Injector {
|
||||
/** @deprecated */ abstract get(token: any, notFoundValue?: any): any;
|
||||
static NULL: Injector;
|
||||
static THROW_IF_NOT_FOUND: Object;
|
||||
static ngInjectableDef: InjectableDef<Injector>;
|
||||
static ngInjectableDef: never;
|
||||
/** @deprecated */ static create(providers: StaticProvider[], parent?: Injector): Injector;
|
||||
static create(options: {
|
||||
providers: StaticProvider[];
|
||||
@ -409,22 +402,9 @@ export declare abstract class Injector {
|
||||
/** @experimental */
|
||||
export declare const INJECTOR: InjectionToken<Injector>;
|
||||
|
||||
/** @experimental */
|
||||
export interface InjectorDef<T> {
|
||||
factory: () => T;
|
||||
imports: (InjectorType<any> | InjectorTypeWithProviders<any>)[];
|
||||
providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export interface InjectorType<T> extends Type<T> {
|
||||
ngInjectorDef: InjectorDef<T>;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export interface InjectorTypeWithProviders<T> {
|
||||
ngModule: InjectorType<T>;
|
||||
providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
|
||||
ngInjectorDef: never;
|
||||
}
|
||||
|
||||
export declare const Input: InputDecorator;
|
||||
@ -462,7 +442,7 @@ export declare class IterableDiffers {
|
||||
/** @deprecated */ factories: IterableDifferFactory[];
|
||||
constructor(factories: IterableDifferFactory[]);
|
||||
find(iterable: any): IterableDifferFactory;
|
||||
static ngInjectableDef: InjectableDef<IterableDiffers>;
|
||||
static ngInjectableDef: never;
|
||||
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
|
||||
static extend(factories: IterableDifferFactory[]): StaticProvider;
|
||||
}
|
||||
|
Reference in New Issue
Block a user