refactor(core): use `unknown` rather than `never` for private properties (#41040)
Before `unknown` was available, the `never` type was used to discourage application developers from using "private" properties. The `unknown` type is much better suited for this. PR Close #41040
This commit is contained in:
parent
d9acaa8547
commit
0f818f36d7
|
@ -419,7 +419,7 @@ export declare abstract class ViewportScroller {
|
||||||
abstract scrollToPosition(position: [number, number]): void;
|
abstract scrollToPosition(position: [number, number]): void;
|
||||||
abstract setHistoryScrollRestoration(scrollRestoration: 'auto' | 'manual'): void;
|
abstract setHistoryScrollRestoration(scrollRestoration: 'auto' | 'manual'): void;
|
||||||
abstract setOffset(offset: [number, number] | (() => [number, number])): void;
|
abstract setOffset(offset: [number, number] | (() => [number, number])): void;
|
||||||
static ɵprov: never;
|
static ɵprov: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare enum WeekDay {
|
export declare enum WeekDay {
|
||||||
|
|
|
@ -421,7 +421,7 @@ export declare interface InjectableDecorator {
|
||||||
export declare type InjectableProvider = ValueSansProvider | ExistingSansProvider | StaticClassSansProvider | ConstructorSansProvider | FactorySansProvider | ClassSansProvider;
|
export declare type InjectableProvider = ValueSansProvider | ExistingSansProvider | StaticClassSansProvider | ConstructorSansProvider | FactorySansProvider | ClassSansProvider;
|
||||||
|
|
||||||
export declare interface InjectableType<T> extends Type<T> {
|
export declare interface InjectableType<T> extends Type<T> {
|
||||||
ɵprov: never;
|
ɵprov: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare interface InjectDecorator {
|
export declare interface InjectDecorator {
|
||||||
|
@ -439,7 +439,7 @@ export declare enum InjectFlags {
|
||||||
|
|
||||||
export declare class InjectionToken<T> {
|
export declare class InjectionToken<T> {
|
||||||
protected _desc: string;
|
protected _desc: string;
|
||||||
readonly ɵprov: never | undefined;
|
readonly ɵprov: unknown;
|
||||||
constructor(_desc: string, options?: {
|
constructor(_desc: string, options?: {
|
||||||
providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
||||||
factory: () => T;
|
factory: () => T;
|
||||||
|
@ -452,7 +452,7 @@ export declare abstract class Injector {
|
||||||
/** @deprecated */ abstract get(token: any, notFoundValue?: any): any;
|
/** @deprecated */ abstract get(token: any, notFoundValue?: any): any;
|
||||||
static NULL: Injector;
|
static NULL: Injector;
|
||||||
static THROW_IF_NOT_FOUND: {};
|
static THROW_IF_NOT_FOUND: {};
|
||||||
static ɵprov: never;
|
static ɵprov: unknown;
|
||||||
/** @deprecated */ static create(providers: StaticProvider[], parent?: Injector): Injector;
|
/** @deprecated */ static create(providers: StaticProvider[], parent?: Injector): Injector;
|
||||||
static create(options: {
|
static create(options: {
|
||||||
providers: StaticProvider[];
|
providers: StaticProvider[];
|
||||||
|
@ -464,7 +464,7 @@ export declare abstract class Injector {
|
||||||
export declare const INJECTOR: InjectionToken<Injector>;
|
export declare const INJECTOR: InjectionToken<Injector>;
|
||||||
|
|
||||||
export declare interface InjectorType<T> extends Type<T> {
|
export declare interface InjectorType<T> extends Type<T> {
|
||||||
ɵinj: never;
|
ɵinj: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare interface Input {
|
export declare interface Input {
|
||||||
|
@ -510,7 +510,7 @@ export declare class IterableDiffers {
|
||||||
/** @deprecated */ factories: IterableDifferFactory[];
|
/** @deprecated */ factories: IterableDifferFactory[];
|
||||||
constructor(factories: IterableDifferFactory[]);
|
constructor(factories: IterableDifferFactory[]);
|
||||||
find(iterable: any): IterableDifferFactory;
|
find(iterable: any): IterableDifferFactory;
|
||||||
static ɵprov: never;
|
static ɵprov: unknown;
|
||||||
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
|
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers;
|
||||||
static extend(factories: IterableDifferFactory[]): StaticProvider;
|
static extend(factories: IterableDifferFactory[]): StaticProvider;
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,7 @@ export declare class KeyValueDiffers {
|
||||||
/** @deprecated */ factories: KeyValueDifferFactory[];
|
/** @deprecated */ factories: KeyValueDifferFactory[];
|
||||||
constructor(factories: KeyValueDifferFactory[]);
|
constructor(factories: KeyValueDifferFactory[]);
|
||||||
find(kv: any): KeyValueDifferFactory;
|
find(kv: any): KeyValueDifferFactory;
|
||||||
static ɵprov: never;
|
static ɵprov: unknown;
|
||||||
static create<S>(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers;
|
static create<S>(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers;
|
||||||
static extend<S>(factories: KeyValueDifferFactory[]): StaticProvider;
|
static extend<S>(factories: KeyValueDifferFactory[]): StaticProvider;
|
||||||
}
|
}
|
||||||
|
@ -676,7 +676,7 @@ export declare function ɵɵdefineInjectable<T>(opts: {
|
||||||
token: unknown;
|
token: unknown;
|
||||||
providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
||||||
factory: () => T;
|
factory: () => T;
|
||||||
}): never;
|
}): unknown;
|
||||||
|
|
||||||
/** @codeGenApi */
|
/** @codeGenApi */
|
||||||
export declare function ɵɵinject<T>(token: Type<T> | AbstractType<T> | InjectionToken<T>): T;
|
export declare function ɵɵinject<T>(token: Type<T> | AbstractType<T> | InjectionToken<T>): T;
|
||||||
|
@ -859,7 +859,7 @@ export declare function resolveForwardRef<T>(type: T): T;
|
||||||
|
|
||||||
export declare abstract class Sanitizer {
|
export declare abstract class Sanitizer {
|
||||||
abstract sanitize(context: SecurityContext, value: {} | string | null): string | null;
|
abstract sanitize(context: SecurityContext, value: {} | string | null): string | null;
|
||||||
static ɵprov: never;
|
static ɵprov: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare interface SchemaMetadata {
|
export declare interface SchemaMetadata {
|
||||||
|
|
|
@ -55,7 +55,7 @@ export class InjectionToken<T> {
|
||||||
/** @internal */
|
/** @internal */
|
||||||
readonly ngMetadataName = 'InjectionToken';
|
readonly ngMetadataName = 'InjectionToken';
|
||||||
|
|
||||||
readonly ɵprov: never|undefined;
|
readonly ɵprov: unknown;
|
||||||
|
|
||||||
constructor(protected _desc: string, options?: {
|
constructor(protected _desc: string, options?: {
|
||||||
providedIn?: Type<any>|'root'|'platform'|'any'|null, factory: () => T
|
providedIn?: Type<any>|'root'|'platform'|'any'|null, factory: () => T
|
||||||
|
@ -82,5 +82,5 @@ export class InjectionToken<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InjectableDefToken<T> extends InjectionToken<T> {
|
export interface InjectableDefToken<T> extends InjectionToken<T> {
|
||||||
ɵprov: never;
|
ɵprov: unknown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ export interface InjectableType<T> extends Type<T> {
|
||||||
/**
|
/**
|
||||||
* Opaque type whose structure is highly version dependent. Do not rely on any properties.
|
* Opaque type whose structure is highly version dependent. Do not rely on any properties.
|
||||||
*/
|
*/
|
||||||
ɵprov: never;
|
ɵprov: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +105,7 @@ export interface InjectorType<T> extends Type<T> {
|
||||||
/**
|
/**
|
||||||
* Opaque type whose structure is highly version dependent. Do not rely on any properties.
|
* Opaque type whose structure is highly version dependent. Do not rely on any properties.
|
||||||
*/
|
*/
|
||||||
ɵinj: never;
|
ɵinj: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,13 +143,13 @@ export interface InjectorTypeWithProviders<T> {
|
||||||
export function ɵɵdefineInjectable<T>(opts: {
|
export function ɵɵdefineInjectable<T>(opts: {
|
||||||
token: unknown,
|
token: unknown,
|
||||||
providedIn?: Type<any>|'root'|'platform'|'any'|null, factory: () => T,
|
providedIn?: Type<any>|'root'|'platform'|'any'|null, factory: () => T,
|
||||||
}): never {
|
}): unknown {
|
||||||
return ({
|
return {
|
||||||
token: opts.token,
|
token: opts.token,
|
||||||
providedIn: opts.providedIn as any || null,
|
providedIn: opts.providedIn as any || null,
|
||||||
factory: opts.factory,
|
factory: opts.factory,
|
||||||
value: undefined,
|
value: undefined,
|
||||||
} as ɵɵInjectableDef<T>) as never;
|
} as ɵɵInjectableDef<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,12 +180,12 @@ export const defineInjectable = ɵɵdefineInjectable;
|
||||||
* @codeGenApi
|
* @codeGenApi
|
||||||
*/
|
*/
|
||||||
export function ɵɵdefineInjector(options: {factory: () => any, providers?: any[], imports?: any[]}):
|
export function ɵɵdefineInjector(options: {factory: () => any, providers?: any[], imports?: any[]}):
|
||||||
never {
|
unknown {
|
||||||
return ({
|
return {
|
||||||
factory: options.factory,
|
factory: options.factory,
|
||||||
providers: options.providers || [],
|
providers: options.providers || [],
|
||||||
imports: options.imports || [],
|
imports: options.imports || [],
|
||||||
} as ɵɵInjectorDef<any>) as never;
|
} as ɵɵInjectorDef<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -288,67 +288,65 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||||
* The set of schemas that declare elements to be allowed in the component's template.
|
* The set of schemas that declare elements to be allowed in the component's template.
|
||||||
*/
|
*/
|
||||||
schemas?: SchemaMetadata[] | null;
|
schemas?: SchemaMetadata[] | null;
|
||||||
}): never {
|
}): unknown {
|
||||||
return noSideEffects(() => {
|
return noSideEffects(() => {
|
||||||
// Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent.
|
// Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent.
|
||||||
// See the `initNgDevMode` docstring for more information.
|
// See the `initNgDevMode` docstring for more information.
|
||||||
(typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
|
(typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
|
||||||
|
|
||||||
const type = componentDefinition.type;
|
const type = componentDefinition.type;
|
||||||
const typePrototype = type.prototype;
|
const declaredInputs: {[key: string]: string} = {} as any;
|
||||||
const declaredInputs: {[key: string]: string} = {} as any;
|
const def: Mutable<ComponentDef<any>, keyof ComponentDef<any>> = {
|
||||||
const def: Mutable<ComponentDef<any>, keyof ComponentDef<any>> = {
|
type: type,
|
||||||
type: type,
|
providersResolver: null,
|
||||||
providersResolver: null,
|
decls: componentDefinition.decls,
|
||||||
decls: componentDefinition.decls,
|
vars: componentDefinition.vars,
|
||||||
vars: componentDefinition.vars,
|
factory: null,
|
||||||
factory: null,
|
template: componentDefinition.template || null!,
|
||||||
template: componentDefinition.template || null!,
|
consts: componentDefinition.consts || null,
|
||||||
consts: componentDefinition.consts || null,
|
ngContentSelectors: componentDefinition.ngContentSelectors,
|
||||||
ngContentSelectors: componentDefinition.ngContentSelectors,
|
hostBindings: componentDefinition.hostBindings || null,
|
||||||
hostBindings: componentDefinition.hostBindings || null,
|
hostVars: componentDefinition.hostVars || 0,
|
||||||
hostVars: componentDefinition.hostVars || 0,
|
hostAttrs: componentDefinition.hostAttrs || null,
|
||||||
hostAttrs: componentDefinition.hostAttrs || null,
|
contentQueries: componentDefinition.contentQueries || null,
|
||||||
contentQueries: componentDefinition.contentQueries || null,
|
declaredInputs: declaredInputs,
|
||||||
declaredInputs: declaredInputs,
|
inputs: null!, // assigned in noSideEffects
|
||||||
inputs: null!, // assigned in noSideEffects
|
outputs: null!, // assigned in noSideEffects
|
||||||
outputs: null!, // assigned in noSideEffects
|
exportAs: componentDefinition.exportAs || null,
|
||||||
exportAs: componentDefinition.exportAs || null,
|
onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
|
||||||
onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
|
directiveDefs: null!, // assigned in noSideEffects
|
||||||
directiveDefs: null!, // assigned in noSideEffects
|
pipeDefs: null!, // assigned in noSideEffects
|
||||||
pipeDefs: null!, // assigned in noSideEffects
|
selectors: componentDefinition.selectors || EMPTY_ARRAY,
|
||||||
selectors: componentDefinition.selectors || EMPTY_ARRAY,
|
viewQuery: componentDefinition.viewQuery || null,
|
||||||
viewQuery: componentDefinition.viewQuery || null,
|
features: componentDefinition.features as DirectiveDefFeature[] || null,
|
||||||
features: componentDefinition.features as DirectiveDefFeature[] || null,
|
data: componentDefinition.data || {},
|
||||||
data: componentDefinition.data || {},
|
// TODO(misko): convert ViewEncapsulation into const enum so that it can be used
|
||||||
// TODO(misko): convert ViewEncapsulation into const enum so that it can be used
|
// directly in the next line. Also `None` should be 0 not 2.
|
||||||
// directly in the next line. Also `None` should be 0 not 2.
|
encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated,
|
||||||
encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated,
|
id: 'c',
|
||||||
id: 'c',
|
styles: componentDefinition.styles || EMPTY_ARRAY,
|
||||||
styles: componentDefinition.styles || EMPTY_ARRAY,
|
_: null,
|
||||||
_: null as never,
|
setInput: null,
|
||||||
setInput: null,
|
schemas: componentDefinition.schemas || null,
|
||||||
schemas: componentDefinition.schemas || null,
|
tView: null,
|
||||||
tView: null,
|
};
|
||||||
};
|
const directiveTypes = componentDefinition.directives!;
|
||||||
const directiveTypes = componentDefinition.directives!;
|
const feature = componentDefinition.features;
|
||||||
const feature = componentDefinition.features;
|
const pipeTypes = componentDefinition.pipes!;
|
||||||
const pipeTypes = componentDefinition.pipes!;
|
def.id += _renderCompCount++;
|
||||||
def.id += _renderCompCount++;
|
def.inputs = invertObject(componentDefinition.inputs, declaredInputs),
|
||||||
def.inputs = invertObject(componentDefinition.inputs, declaredInputs),
|
def.outputs = invertObject(componentDefinition.outputs),
|
||||||
def.outputs = invertObject(componentDefinition.outputs),
|
feature && feature.forEach((fn) => fn(def));
|
||||||
feature && feature.forEach((fn) => fn(def));
|
def.directiveDefs = directiveTypes ?
|
||||||
def.directiveDefs = directiveTypes ?
|
() => (typeof directiveTypes === 'function' ? directiveTypes() : directiveTypes)
|
||||||
() => (typeof directiveTypes === 'function' ? directiveTypes() : directiveTypes)
|
.map(extractDirectiveDef) :
|
||||||
.map(extractDirectiveDef) :
|
null;
|
||||||
null;
|
def.pipeDefs = pipeTypes ?
|
||||||
def.pipeDefs = pipeTypes ?
|
() => (typeof pipeTypes === 'function' ? pipeTypes() : pipeTypes).map(extractPipeDef) :
|
||||||
() =>
|
null;
|
||||||
(typeof pipeTypes === 'function' ? pipeTypes() : pipeTypes).map(extractPipeDef) :
|
|
||||||
null;
|
|
||||||
|
|
||||||
return def as never;
|
return def;
|
||||||
}) as never;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -412,7 +410,7 @@ export function ɵɵdefineNgModule<T>(def: {
|
||||||
|
|
||||||
/** Unique ID for the module that is used with `getModuleFactory`. */
|
/** Unique ID for the module that is used with `getModuleFactory`. */
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
}): never {
|
}): unknown {
|
||||||
const res: NgModuleDef<T> = {
|
const res: NgModuleDef<T> = {
|
||||||
type: def.type,
|
type: def.type,
|
||||||
bootstrap: def.bootstrap || EMPTY_ARRAY,
|
bootstrap: def.bootstrap || EMPTY_ARRAY,
|
||||||
|
@ -428,7 +426,7 @@ export function ɵɵdefineNgModule<T>(def: {
|
||||||
autoRegisterModuleById[def.id!] = def.type as unknown as NgModuleType;
|
autoRegisterModuleById[def.id!] = def.type as unknown as NgModuleType;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return res as never;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -453,13 +451,13 @@ export function ɵɵsetNgModuleScope(type: any, scope: {
|
||||||
* module.
|
* module.
|
||||||
*/
|
*/
|
||||||
exports?: Type<any>[] | (() => Type<any>[]);
|
exports?: Type<any>[] | (() => Type<any>[]);
|
||||||
}): void {
|
}): unknown {
|
||||||
return noSideEffects(() => {
|
return noSideEffects(() => {
|
||||||
const ngModuleDef = getNgModuleDef(type, true);
|
const ngModuleDef = getNgModuleDef(type, true);
|
||||||
ngModuleDef.declarations = scope.declarations || EMPTY_ARRAY;
|
ngModuleDef.declarations = scope.declarations || EMPTY_ARRAY;
|
||||||
ngModuleDef.imports = scope.imports || EMPTY_ARRAY;
|
ngModuleDef.imports = scope.imports || EMPTY_ARRAY;
|
||||||
ngModuleDef.exports = scope.exports || EMPTY_ARRAY;
|
ngModuleDef.exports = scope.exports || EMPTY_ARRAY;
|
||||||
}) as never;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -718,14 +716,14 @@ export function ɵɵdefinePipe<T>(pipeDef: {
|
||||||
|
|
||||||
/** Whether the pipe is pure. */
|
/** Whether the pipe is pure. */
|
||||||
pure?: boolean
|
pure?: boolean
|
||||||
}): never {
|
}): unknown {
|
||||||
return (<PipeDef<T>>{
|
return (<PipeDef<T>>{
|
||||||
type: pipeDef.type,
|
type: pipeDef.type,
|
||||||
name: pipeDef.name,
|
name: pipeDef.name,
|
||||||
factory: null,
|
factory: null,
|
||||||
pure: pipeDef.pure !== false,
|
pure: pipeDef.pure !== false,
|
||||||
onDestroy: pipeDef.type.prototype.ngOnDestroy || null
|
onDestroy: pipeDef.type.prototype.ngOnDestroy || null
|
||||||
}) as never;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function throwMultipleComponentError(tNode: TNode): never {
|
||||||
|
|
||||||
/** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */
|
/** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */
|
||||||
export function throwErrorIfNoChangesMode(
|
export function throwErrorIfNoChangesMode(
|
||||||
creationMode: boolean, oldValue: any, currValue: any, propName?: string): never|void {
|
creationMode: boolean, oldValue: any, currValue: any, propName?: string): never {
|
||||||
const field = propName ? ` for '${propName}'` : '';
|
const field = propName ? ` for '${propName}'` : '';
|
||||||
let msg =
|
let msg =
|
||||||
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${
|
`ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${
|
||||||
|
|
|
@ -59,7 +59,7 @@ export const enum RenderFlags {
|
||||||
* consumable for rendering.
|
* consumable for rendering.
|
||||||
*/
|
*/
|
||||||
export interface ComponentType<T> extends Type<T> {
|
export interface ComponentType<T> extends Type<T> {
|
||||||
ɵcmp: never;
|
ɵcmp: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +67,8 @@ export interface ComponentType<T> extends Type<T> {
|
||||||
* consumable for rendering.
|
* consumable for rendering.
|
||||||
*/
|
*/
|
||||||
export interface DirectiveType<T> extends Type<T> {
|
export interface DirectiveType<T> extends Type<T> {
|
||||||
ɵdir: never;
|
ɵdir: unknown;
|
||||||
ɵfac: () => T;
|
ɵfac: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +76,7 @@ export interface DirectiveType<T> extends Type<T> {
|
||||||
* consumable for rendering.
|
* consumable for rendering.
|
||||||
*/
|
*/
|
||||||
export interface PipeType<T> extends Type<T> {
|
export interface PipeType<T> extends Type<T> {
|
||||||
ɵpipe: never;
|
ɵpipe: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -370,7 +370,7 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
|
||||||
* Used to store the result of `noSideEffects` function so that it is not removed by closure
|
* Used to store the result of `noSideEffects` function so that it is not removed by closure
|
||||||
* compiler. The property should never be read.
|
* compiler. The property should never be read.
|
||||||
*/
|
*/
|
||||||
readonly _?: never;
|
readonly _?: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -250,7 +250,7 @@ export function getLocalRefs(target: {}): {[key: string]: any} {
|
||||||
* @globalApi ng
|
* @globalApi ng
|
||||||
*/
|
*/
|
||||||
export function getHostElement(componentOrDirective: {}): Element {
|
export function getHostElement(componentOrDirective: {}): Element {
|
||||||
return getLContext(componentOrDirective)!.native as never as Element;
|
return getLContext(componentOrDirective)!.native as unknown as Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1419,7 +1419,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
static ɵprov: ɵɵInjectableDef<Bar> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: Bar,
|
token: Bar,
|
||||||
factory: () => new Bar(),
|
factory: () => new Bar(),
|
||||||
providedIn: SomeModule,
|
providedIn: SomeModule,
|
||||||
|
@ -1452,7 +1452,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
static ɵprov: ɵɵInjectableDef<Bar> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: Bar,
|
token: Bar,
|
||||||
factory: () => new Bar(),
|
factory: () => new Bar(),
|
||||||
providedIn: SomeModule,
|
providedIn: SomeModule,
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Component, Injectable, ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdirectiveInject, ɵɵProvidersFeature} from '@angular/core/src/core';
|
import {Component, Injectable, ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdirectiveInject, ɵɵProvidersFeature} from '@angular/core/src/core';
|
||||||
import {getLContext} from '@angular/core/src/render3/context_discovery';
|
import {ComponentDef, DirectiveDef} from '@angular/core/src/render3';
|
||||||
import {ɵɵelement, ɵɵelementEnd, ɵɵelementStart} from '@angular/core/src/render3/instructions/element';
|
import {ɵɵelement, ɵɵelementEnd, ɵɵelementStart} from '@angular/core/src/render3/instructions/element';
|
||||||
import {TNodeDebug} from '@angular/core/src/render3/instructions/lview_debug';
|
import {TNodeDebug} from '@angular/core/src/render3/instructions/lview_debug';
|
||||||
import {createTNode, createTView} from '@angular/core/src/render3/instructions/shared';
|
import {createTNode, createTView} from '@angular/core/src/render3/instructions/shared';
|
||||||
|
@ -227,7 +227,10 @@ describe('lView_debug', () => {
|
||||||
expect(myCompNode.injector).toEqual({
|
expect(myCompNode.injector).toEqual({
|
||||||
bloom: jasmine.anything(),
|
bloom: jasmine.anything(),
|
||||||
cumulativeBloom: jasmine.anything(),
|
cumulativeBloom: jasmine.anything(),
|
||||||
providers: [DepA, String, MyComponent.ɵcmp, MyDirective.ɵdir],
|
providers: [
|
||||||
|
DepA, String, MyComponent.ɵcmp as ComponentDef<MyComponent>,
|
||||||
|
MyDirective.ɵdir as DirectiveDef<MyDirective>
|
||||||
|
],
|
||||||
viewProviders: [DepB, Number],
|
viewProviders: [DepB, Number],
|
||||||
parentInjectorIndex: -1,
|
parentInjectorIndex: -1,
|
||||||
});
|
});
|
||||||
|
|
|
@ -294,13 +294,13 @@ export function renderTemplate<T>(
|
||||||
providedRendererFactory, renderer, null, null);
|
providedRendererFactory, renderer, null, null);
|
||||||
enterView(hostLView);
|
enterView(hostLView);
|
||||||
|
|
||||||
const def: ComponentDef<any> = ɵɵdefineComponent({
|
const def = ɵɵdefineComponent({
|
||||||
type: Object,
|
type: Object,
|
||||||
template: templateFn,
|
template: templateFn,
|
||||||
decls: decls,
|
decls: decls,
|
||||||
vars: vars,
|
vars: vars,
|
||||||
consts: consts,
|
consts: consts,
|
||||||
});
|
}) as ComponentDef<any>;
|
||||||
def.directiveDefs = directives || null;
|
def.directiveDefs = directives || null;
|
||||||
def.pipeDefs = pipes || null;
|
def.pipeDefs = pipes || null;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {NgModuleRef, ɵINJECTOR_SCOPE as INJECTOR_SCOPE} from '@angular/core';
|
||||||
import {inject, InjectFlags} from '@angular/core/src/di';
|
import {inject, InjectFlags} from '@angular/core/src/di';
|
||||||
import {Injector} from '@angular/core/src/di/injector';
|
import {Injector} from '@angular/core/src/di/injector';
|
||||||
import {INJECTOR} from '@angular/core/src/di/injector_token';
|
import {INJECTOR} from '@angular/core/src/di/injector_token';
|
||||||
import {ɵɵdefineInjectable, ɵɵInjectableDef} from '@angular/core/src/di/interface/defs';
|
import {ɵɵdefineInjectable} from '@angular/core/src/di/interface/defs';
|
||||||
import {NgModuleDefinition, NgModuleProviderDef, NodeFlags} from '@angular/core/src/view';
|
import {NgModuleDefinition, NgModuleProviderDef, NodeFlags} from '@angular/core/src/view';
|
||||||
import {moduleDef} from '@angular/core/src/view/ng_module';
|
import {moduleDef} from '@angular/core/src/view/ng_module';
|
||||||
import {createNgModuleRef} from '@angular/core/src/view/refs';
|
import {createNgModuleRef} from '@angular/core/src/view/refs';
|
||||||
|
@ -25,7 +25,7 @@ class MyChildModule {}
|
||||||
class NotMyModule {}
|
class NotMyModule {}
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
static ɵprov: ɵɵInjectableDef<Bar> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: Bar,
|
token: Bar,
|
||||||
factory: () => new Bar(),
|
factory: () => new Bar(),
|
||||||
providedIn: MyModule,
|
providedIn: MyModule,
|
||||||
|
@ -33,7 +33,7 @@ class Bar {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Baz {
|
class Baz {
|
||||||
static ɵprov: ɵɵInjectableDef<Baz> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: Baz,
|
token: Baz,
|
||||||
factory: () => new Baz(),
|
factory: () => new Baz(),
|
||||||
providedIn: NotMyModule,
|
providedIn: NotMyModule,
|
||||||
|
@ -43,7 +43,7 @@ class Baz {
|
||||||
class HasNormalDep {
|
class HasNormalDep {
|
||||||
constructor(public foo: Foo) {}
|
constructor(public foo: Foo) {}
|
||||||
|
|
||||||
static ɵprov: ɵɵInjectableDef<HasNormalDep> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: HasNormalDep,
|
token: HasNormalDep,
|
||||||
factory: () => new HasNormalDep(inject(Foo)),
|
factory: () => new HasNormalDep(inject(Foo)),
|
||||||
providedIn: MyModule,
|
providedIn: MyModule,
|
||||||
|
@ -53,7 +53,7 @@ class HasNormalDep {
|
||||||
class HasDefinedDep {
|
class HasDefinedDep {
|
||||||
constructor(public bar: Bar) {}
|
constructor(public bar: Bar) {}
|
||||||
|
|
||||||
static ɵprov: ɵɵInjectableDef<HasDefinedDep> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: HasDefinedDep,
|
token: HasDefinedDep,
|
||||||
factory: () => new HasDefinedDep(inject(Bar)),
|
factory: () => new HasDefinedDep(inject(Bar)),
|
||||||
providedIn: MyModule,
|
providedIn: MyModule,
|
||||||
|
@ -63,7 +63,7 @@ class HasDefinedDep {
|
||||||
class HasOptionalDep {
|
class HasOptionalDep {
|
||||||
constructor(public baz: Baz|null) {}
|
constructor(public baz: Baz|null) {}
|
||||||
|
|
||||||
static ɵprov: ɵɵInjectableDef<HasOptionalDep> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: HasOptionalDep,
|
token: HasOptionalDep,
|
||||||
factory: () => new HasOptionalDep(inject(Baz, InjectFlags.Optional)),
|
factory: () => new HasOptionalDep(inject(Baz, InjectFlags.Optional)),
|
||||||
providedIn: MyModule,
|
providedIn: MyModule,
|
||||||
|
@ -71,7 +71,7 @@ class HasOptionalDep {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChildDep {
|
class ChildDep {
|
||||||
static ɵprov: ɵɵInjectableDef<ChildDep> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: ChildDep,
|
token: ChildDep,
|
||||||
factory: () => new ChildDep(),
|
factory: () => new ChildDep(),
|
||||||
providedIn: MyChildModule,
|
providedIn: MyChildModule,
|
||||||
|
@ -80,7 +80,7 @@ class ChildDep {
|
||||||
|
|
||||||
class FromChildWithOptionalDep {
|
class FromChildWithOptionalDep {
|
||||||
constructor(public baz: Baz|null) {}
|
constructor(public baz: Baz|null) {}
|
||||||
static ɵprov: ɵɵInjectableDef<FromChildWithOptionalDep> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: FromChildWithOptionalDep,
|
token: FromChildWithOptionalDep,
|
||||||
factory: () => new FromChildWithOptionalDep(inject(Baz, InjectFlags.Default)),
|
factory: () => new FromChildWithOptionalDep(inject(Baz, InjectFlags.Default)),
|
||||||
providedIn: MyChildModule,
|
providedIn: MyChildModule,
|
||||||
|
@ -91,7 +91,7 @@ class FromChildWithSkipSelfDep {
|
||||||
constructor(
|
constructor(
|
||||||
public skipSelfChildDep: ChildDep|null, public selfChildDep: ChildDep|null,
|
public skipSelfChildDep: ChildDep|null, public selfChildDep: ChildDep|null,
|
||||||
public optionalSelfBar: Bar|null) {}
|
public optionalSelfBar: Bar|null) {}
|
||||||
static ɵprov: ɵɵInjectableDef<FromChildWithSkipSelfDep> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: FromChildWithSkipSelfDep,
|
token: FromChildWithSkipSelfDep,
|
||||||
factory: () => new FromChildWithSkipSelfDep(
|
factory: () => new FromChildWithSkipSelfDep(
|
||||||
inject(ChildDep, InjectFlags.SkipSelf|InjectFlags.Optional),
|
inject(ChildDep, InjectFlags.SkipSelf|InjectFlags.Optional),
|
||||||
|
@ -228,7 +228,7 @@ describe('NgModuleRef_ injector', () => {
|
||||||
Service.destroyed++;
|
Service.destroyed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ɵprov: ɵɵInjectableDef<Service> = ɵɵdefineInjectable({
|
static ɵprov = ɵɵdefineInjectable({
|
||||||
token: Service,
|
token: Service,
|
||||||
factory: () => new Service(),
|
factory: () => new Service(),
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
|
Loading…
Reference in New Issue