refactor(ivy): make return value of define(Component|Directive|Pipe|Injector|Injectable) private (#23371)

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 `OpaqueToken`.

By prefixing the type with `ɵ` we are communicating the the outside world that
the value is not public API and is subject to change without backward compatibility.

PR Close #23371
This commit is contained in:
Miško Hevery
2018-04-13 13:34:39 -07:00
committed by Igor Minar
parent f4017ce5e3
commit 2c09b707ce
32 changed files with 179 additions and 172 deletions

View File

@ -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>;
}): ɵInjectableDef<T>;
/** @experimental */
export declare function defineInjector(options: {
factory: () => any;
providers?: any[];
imports?: any[];
}): InjectorDef<any>;
}): ɵInjectorDef<any>;
/** @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: ɵInjectableDef<T>;
}
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: ɵInjectableDef<T> | 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: ɵInjectableDef<Injector>;
/** @deprecated */ static create(providers: StaticProvider[], parent?: Injector): Injector;
static create(options: {
providers: StaticProvider[];
@ -409,16 +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>;
ngInjectorDef: ɵInjectorDef<T>;
}
/** @experimental */
@ -462,7 +448,7 @@ export declare class IterableDiffers {
/** @deprecated */ factories: IterableDifferFactory[];
constructor(factories: IterableDifferFactory[]);
find(iterable: any): IterableDifferFactory;
static ngInjectableDef: InjectableDef<IterableDiffers>;
static ngInjectableDef: ɵInjectableDef<IterableDiffers>;
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
static extend(factories: IterableDifferFactory[]): StaticProvider;
}