From 79466baef877c82b2d314db7259a990e47367bbb Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Fri, 21 Sep 2018 12:12:06 -0700 Subject: [PATCH] fix(ivy): remove metadata from *Def and introduce *DefWithMeta types (#26203) Previously in Ivy, metadata for directives/components/modules/etc was carried in .d.ts files inside type information encoded on the DirectiveDef, ComponentDef, NgModuleDef, etc types of Ivy definition fields. This works well, but has the side effect of complicating Ivy's runtime code as these extra generic type parameters had to be specified as throughout the codebase. *DefInternal types were introduced previously to mitigate this issue, but that's the wrong way to solve the problem. This commit returns *Def types to their original form, with no metadata attached. Instead, new *DefWithMeta types are introduced that alias the plain definition types and add extra generic parameters. This way the only code that needs to deal with the extra metadata parameters is the compiler code that reads and writes them - the existence of this metadata is transparent to the runtime, as it should be. PR Close #26203 --- .../src/largetable/render3/table.ts | 4 +- .../ngtsc/annotations/src/selector_scope.ts | 4 +- .../annotations/test/selector_scope_spec.ts | 12 ++--- .../src/ngtsc/transform/src/translator.ts | 13 ++++- .../compiler-cli/test/ngtsc/ngtsc_spec.ts | 23 ++++++--- .../compiler/src/render3/r3_identifiers.ts | 14 ++--- .../src/render3/r3_module_compiler.ts | 2 +- .../compiler/src/render3/r3_pipe_compiler.ts | 2 +- .../compiler/src/render3/view/compiler.ts | 43 +++++++++++++--- .../core/src/core_render3_private_export.ts | 6 ++- packages/core/src/metadata/ng_module.ts | 8 +-- packages/core/src/render3/component.ts | 8 +-- packages/core/src/render3/component_ref.ts | 4 +- packages/core/src/render3/definition.ts | 24 ++++----- packages/core/src/render3/di.ts | 10 ++-- .../features/inherit_definition_feature.ts | 17 +++---- .../render3/features/ng_onchanges_feature.ts | 4 +- .../src/render3/features/public_feature.ts | 4 +- packages/core/src/render3/hooks.ts | 10 ++-- packages/core/src/render3/index.ts | 7 +-- packages/core/src/render3/instructions.ts | 36 +++++++------ .../core/src/render3/interfaces/definition.ts | 41 +++++++-------- packages/core/src/render3/interfaces/view.ts | 6 +-- packages/core/src/render3/jit/module.ts | 14 ++--- packages/core/src/render3/ng_module_ref.ts | 4 +- packages/core/src/render3/pipe.ts | 10 ++-- packages/core/src/render3/query.ts | 4 +- .../Inherit_definition_feature_spec.ts | 26 +++++----- .../component_directives_spec.ts | 51 +++++++++---------- .../compiler_canonical/elements_spec.ts | 5 +- .../compiler_canonical/life_cycle_spec.ts | 5 +- .../render3/compiler_canonical/pipes_spec.ts | 8 +-- .../render3/compiler_canonical/query_spec.ts | 6 +-- .../compiler_canonical/small_app_spec.ts | 2 +- .../template_variables_spec.ts | 4 +- packages/core/test/render3/component_spec.ts | 6 +-- packages/core/test/render3/ivy/jit_spec.ts | 16 +++--- .../core/test/render3/jit_environment_spec.ts | 8 +-- .../render3/ng_on_changes_feature_spec.ts | 40 +++++++-------- packages/core/test/render3/render_util.ts | 10 ++-- .../test/render3/view_container_ref_spec.ts | 2 +- packages/core/testing/src/r3_test_bed.ts | 8 +-- 42 files changed, 279 insertions(+), 252 deletions(-) diff --git a/modules/benchmarks/src/largetable/render3/table.ts b/modules/benchmarks/src/largetable/render3/table.ts index d57cf0cc60..a9420c96d8 100644 --- a/modules/benchmarks/src/largetable/render3/table.ts +++ b/modules/benchmarks/src/largetable/render3/table.ts @@ -7,7 +7,7 @@ */ import {ɵRenderFlags, ɵbind, ɵcontainer, ɵcontainerRefreshEnd, ɵcontainerRefreshStart, ɵdefineComponent, ɵdetectChanges, ɵelementEnd, ɵelementStart, ɵelementStyleProp, ɵelementStyling, ɵembeddedViewEnd, ɵembeddedViewStart, ɵtext, ɵtextBinding as ɵtextBinding} from '@angular/core'; -import {ComponentDefInternal} from '@angular/core/src/render3/interfaces/definition'; +import {ComponentDef} from '@angular/core/src/render3/interfaces/definition'; import {TableCell, buildTable, emptyTable} from '../util'; @@ -16,7 +16,7 @@ export class LargeTableComponent { data: TableCell[][] = emptyTable; /** @nocollapse */ - static ngComponentDef: ComponentDefInternal = ɵdefineComponent({ + static ngComponentDef: ComponentDef = ɵdefineComponent({ type: LargeTableComponent, selectors: [['largetable']], consts: 3, diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/selector_scope.ts b/packages/compiler-cli/src/ngtsc/annotations/src/selector_scope.ts index 07e61af38a..ec849c35c5 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/selector_scope.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/selector_scope.ts @@ -313,7 +313,7 @@ export class SelectorScopeRegistry { return null; } else if ( def.type === null || !ts.isTypeReferenceNode(def.type) || - def.type.typeArguments === undefined || def.type.typeArguments.length !== 2) { + def.type.typeArguments === undefined || def.type.typeArguments.length < 2) { // The type metadata was the wrong shape. return null; } @@ -337,7 +337,7 @@ export class SelectorScopeRegistry { return null; } else if ( def.type === null || !ts.isTypeReferenceNode(def.type) || - def.type.typeArguments === undefined || def.type.typeArguments.length !== 2) { + def.type.typeArguments === undefined || def.type.typeArguments.length < 2) { // The type metadata was the wrong shape. return null; } diff --git a/packages/compiler-cli/src/ngtsc/annotations/test/selector_scope_spec.ts b/packages/compiler-cli/src/ngtsc/annotations/test/selector_scope_spec.ts index d45fde154a..059d6e8933 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/test/selector_scope_spec.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/test/selector_scope_spec.ts @@ -20,7 +20,7 @@ describe('SelectorScopeRegistry', () => { { name: 'node_modules/@angular/core/index.d.ts', contents: ` - export interface NgComponentDef {} + export interface NgComponentDefWithMeta {} export interface NgModuleDef {} ` }, @@ -38,10 +38,10 @@ describe('SelectorScopeRegistry', () => { { name: 'node_modules/some_library/component.d.ts', contents: ` - import {NgComponentDef} from '@angular/core'; + import {NgComponentDefWithMeta} from '@angular/core'; export declare class SomeCmp { - static ngComponentDef: NgComponentDef; + static ngComponentDef: NgComponentDefWithMeta; } ` }, @@ -84,21 +84,21 @@ describe('SelectorScopeRegistry', () => { { name: 'node_modules/@angular/core/index.d.ts', contents: ` - export interface NgComponentDef {} + export interface NgComponentDefWithMeta {} export interface NgModuleDef {} ` }, { name: 'node_modules/some_library/index.d.ts', contents: ` - import {NgComponentDef, NgModuleDef} from '@angular/core'; + import {NgComponentDefWithMeta, NgModuleDef} from '@angular/core'; export declare class SomeModule { static ngModuleDef: NgModuleDef; } export declare class SomeCmp { - static ngComponentDef: NgComponentDef; + static ngComponentDef: NgComponentDefWithMeta; } ` }, diff --git a/packages/compiler-cli/src/ngtsc/transform/src/translator.ts b/packages/compiler-cli/src/ngtsc/transform/src/translator.ts index c8067167ad..2dd71510cf 100644 --- a/packages/compiler-cli/src/ngtsc/transform/src/translator.ts +++ b/packages/compiler-cli/src/ngtsc/transform/src/translator.ts @@ -45,7 +45,7 @@ const CORE_SUPPORTED_SYMBOLS = new Set([ 'inject', 'ɵInjectableDef', 'ɵInjectorDef', - 'ɵNgModuleDef', + 'ɵNgModuleDefWithMeta', 'ɵNgModuleFactory', ]); @@ -416,7 +416,16 @@ export class TypeTranslatorVisitor implements ExpressionVisitor, TypeVisitor { } visitLiteralMapExpr(ast: LiteralMapExpr, context: Context) { - throw new Error('Method not implemented.'); + const entries = ast.entries.map(entry => { + const {key, quoted} = entry; + const value = entry.value.visitExpression(this, context); + if (quoted) { + return `'${key}': ${value}`; + } else { + return `${key}: ${value}`; + } + }); + return `{${entries.join(', ')}}`; } visitCommaExpr(ast: CommaExpr, context: Context) { throw new Error('Method not implemented.'); } diff --git a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts index 130e1dd8ba..3503d95c1e 100644 --- a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts +++ b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts @@ -148,7 +148,9 @@ describe('ngtsc behavioral tests', () => { expect(jsContents).not.toContain('__decorate'); const dtsContents = getContents('test.d.ts'); - expect(dtsContents).toContain('static ngComponentDef: i0.ɵComponentDef'); + expect(dtsContents) + .toContain( + 'static ngComponentDef: i0.ɵComponentDefWithMeta'); }); it('should compile Components without errors', () => { @@ -201,10 +203,12 @@ describe('ngtsc behavioral tests', () => { 'declarations: [TestCmp], imports: [], exports: [] })'); const dtsContents = getContents('test.d.ts'); - expect(dtsContents).toContain('static ngComponentDef: i0.ɵComponentDef'); expect(dtsContents) .toContain( - 'static ngModuleDef: i0.ɵNgModuleDef'); + 'static ngComponentDef: i0.ɵComponentDefWithMeta'); + expect(dtsContents) + .toContain( + 'static ngModuleDef: i0.ɵNgModuleDefWithMeta'); expect(dtsContents).not.toContain('__decorate'); }); @@ -247,7 +251,7 @@ describe('ngtsc behavioral tests', () => { const dtsContents = getContents('test.d.ts'); expect(dtsContents) .toContain( - 'static ngModuleDef: i0.ɵNgModuleDef'); + 'static ngModuleDef: i0.ɵNgModuleDefWithMeta'); expect(dtsContents).toContain('static ngInjectorDef: i0.ɵInjectorDef'); }); @@ -333,7 +337,8 @@ describe('ngtsc behavioral tests', () => { .toContain( 'TestPipe.ngPipeDef = i0.ɵdefinePipe({ name: "test-pipe", type: TestPipe, ' + 'factory: function TestPipe_Factory(t) { return new (t || TestPipe)(); }, pure: false })'); - expect(dtsContents).toContain('static ngPipeDef: i0.ɵPipeDef;'); + expect(dtsContents) + .toContain('static ngPipeDef: i0.ɵPipeDefWithMeta;'); }); it('should compile pure Pipes without errors', () => { @@ -358,7 +363,8 @@ describe('ngtsc behavioral tests', () => { .toContain( 'TestPipe.ngPipeDef = i0.ɵdefinePipe({ name: "test-pipe", type: TestPipe, ' + 'factory: function TestPipe_Factory(t) { return new (t || TestPipe)(); }, pure: true })'); - expect(dtsContents).toContain('static ngPipeDef: i0.ɵPipeDef;'); + expect(dtsContents) + .toContain('static ngPipeDef: i0.ɵPipeDefWithMeta;'); }); it('should compile Pipes with dependencies', () => { @@ -409,7 +415,8 @@ describe('ngtsc behavioral tests', () => { const dtsContents = getContents('test.d.ts'); expect(dtsContents) - .toContain('i0.ɵNgModuleDef'); + .toContain( + 'i0.ɵNgModuleDefWithMeta'); }); it('should unwrap a ModuleWithProviders function if a generic type is provided for it', () => { @@ -440,7 +447,7 @@ describe('ngtsc behavioral tests', () => { const dtsContents = getContents('test.d.ts'); expect(dtsContents).toContain(`import * as i1 from 'router';`); expect(dtsContents) - .toContain('i0.ɵNgModuleDef'); + .toContain('i0.ɵNgModuleDefWithMeta'); }); it('should inject special types according to the metadata', () => { diff --git a/packages/compiler/src/render3/r3_identifiers.ts b/packages/compiler/src/render3/r3_identifiers.ts index ee82bc116d..0ed1b8f9e2 100644 --- a/packages/compiler/src/render3/r3_identifiers.ts +++ b/packages/compiler/src/render3/r3_identifiers.ts @@ -126,8 +126,8 @@ export class Identifiers { static defineComponent: o.ExternalReference = {name: 'ɵdefineComponent', moduleName: CORE}; - static ComponentDef: o.ExternalReference = { - name: 'ɵComponentDef', + static ComponentDefWithMeta: o.ExternalReference = { + name: 'ɵComponentDefWithMeta', moduleName: CORE, }; @@ -136,8 +136,8 @@ export class Identifiers { moduleName: CORE, }; - static DirectiveDef: o.ExternalReference = { - name: 'ɵDirectiveDef', + static DirectiveDefWithMeta: o.ExternalReference = { + name: 'ɵDirectiveDefWithMeta', moduleName: CORE, }; @@ -151,14 +151,14 @@ export class Identifiers { moduleName: CORE, }; - static NgModuleDef: o.ExternalReference = { - name: 'ɵNgModuleDef', + static NgModuleDefWithMeta: o.ExternalReference = { + name: 'ɵNgModuleDefWithMeta', moduleName: CORE, }; static defineNgModule: o.ExternalReference = {name: 'ɵdefineNgModule', moduleName: CORE}; - static PipeDef: o.ExternalReference = {name: 'ɵPipeDef', moduleName: CORE}; + static PipeDefWithMeta: o.ExternalReference = {name: 'ɵPipeDefWithMeta', moduleName: CORE}; static definePipe: o.ExternalReference = {name: 'ɵdefinePipe', moduleName: CORE}; diff --git a/packages/compiler/src/render3/r3_module_compiler.ts b/packages/compiler/src/render3/r3_module_compiler.ts index 932c5c3910..18be544a79 100644 --- a/packages/compiler/src/render3/r3_module_compiler.ts +++ b/packages/compiler/src/render3/r3_module_compiler.ts @@ -73,7 +73,7 @@ export function compileNgModule(meta: R3NgModuleMetadata): R3NgModuleDef { exports: o.literalArr(exports.map(ref => ref.value)), })]); - const type = new o.ExpressionType(o.importExpr(R3.NgModuleDef, [ + const type = new o.ExpressionType(o.importExpr(R3.NgModuleDefWithMeta, [ new o.ExpressionType(moduleType), tupleTypeOf(declarations), tupleTypeOf(imports), tupleTypeOf(exports) ])); diff --git a/packages/compiler/src/render3/r3_pipe_compiler.ts b/packages/compiler/src/render3/r3_pipe_compiler.ts index 569b8ab6bb..2e35262710 100644 --- a/packages/compiler/src/render3/r3_pipe_compiler.ts +++ b/packages/compiler/src/render3/r3_pipe_compiler.ts @@ -50,7 +50,7 @@ export function compilePipeFromMetadata(metadata: R3PipeMetadata) { definitionMapValues.push({key: 'pure', value: o.literal(metadata.pure), quoted: false}); const expression = o.importExpr(R3.definePipe).callFn([o.literalMap(definitionMapValues)]); - const type = new o.ExpressionType(o.importExpr(R3.PipeDef, [ + const type = new o.ExpressionType(o.importExpr(R3.PipeDefWithMeta, [ new o.ExpressionType(metadata.type), new o.ExpressionType(new o.LiteralExpr(metadata.pipeName)), ])); diff --git a/packages/compiler/src/render3/view/compiler.ts b/packages/compiler/src/render3/view/compiler.ts index fccdb6b3f3..cba03fbc32 100644 --- a/packages/compiler/src/render3/view/compiler.ts +++ b/packages/compiler/src/render3/view/compiler.ts @@ -117,10 +117,7 @@ export function compileDirectiveFromMetadata( // string literal, which must be on one line. const selectorForType = (meta.selector || '').replace(/\n/g, ''); - const type = new o.ExpressionType(o.importExpr(R3.DirectiveDef, [ - typeWithParameters(meta.type, meta.typeArgumentCount), - new o.ExpressionType(o.literal(selectorForType)) - ])); + const type = createTypeForDef(meta, R3.DirectiveDefWithMeta); return {expression, type, statements}; } @@ -257,10 +254,7 @@ export function compileComponentFromMetadata( const selectorForType = (meta.selector || '').replace(/\n/g, ''); const expression = o.importExpr(R3.defineComponent).callFn([definitionMap.toLiteralMap()]); - const type = new o.ExpressionType(o.importExpr(R3.ComponentDef, [ - typeWithParameters(meta.type, meta.typeArgumentCount), - new o.ExpressionType(o.literal(selectorForType)) - ])); + const type = createTypeForDef(meta, R3.ComponentDefWithMeta); return {expression, type, statements}; } @@ -509,6 +503,39 @@ function createContentQueriesRefreshFunction(meta: R3DirectiveMetadata): o.Expre return null; } +function stringAsType(str: string): o.Type { + return o.expressionType(o.literal(str)); +} + +function stringMapAsType(map: {[key: string]: string}): o.Type { + const mapValues = Object.keys(map).map(key => ({ + key, + value: o.literal(map[key]), + quoted: true, + })); + return o.expressionType(o.literalMap(mapValues)); +} + +function stringArrayAsType(arr: string[]): o.Type { + return arr.length > 0 ? o.expressionType(o.literalArr(arr.map(value => o.literal(value)))) : + o.NONE_TYPE; +} + +function createTypeForDef(meta: R3DirectiveMetadata, typeBase: o.ExternalReference): o.Type { + // On the type side, remove newlines from the selector as it will need to fit into a TypeScript + // string literal, which must be on one line. + const selectorForType = (meta.selector || '').replace(/\n/g, ''); + + return o.expressionType(o.importExpr(typeBase, [ + typeWithParameters(meta.type, meta.typeArgumentCount), + stringAsType(selectorForType), + meta.exportAs !== null ? stringAsType(meta.exportAs) : o.NONE_TYPE, + stringMapAsType(meta.inputs), + stringMapAsType(meta.outputs), + stringArrayAsType(meta.queries.map(q => q.propertyName)), + ])); +} + // Define and update any view queries function createViewQueriesFunction( meta: R3ComponentMetadata, constantPool: ConstantPool): o.Expression { diff --git a/packages/core/src/core_render3_private_export.ts b/packages/core/src/core_render3_private_export.ts index f293a8109d..b2ef5d6372 100644 --- a/packages/core/src/core_render3_private_export.ts +++ b/packages/core/src/core_render3_private_export.ts @@ -100,9 +100,11 @@ export { pipe as ɵpipe, BaseDef as ɵBaseDef, ComponentDef as ɵComponentDef, - ComponentDefInternal as ɵComponentDefInternal, + ComponentDefWithMeta as ɵComponentDefWithMeta, DirectiveDef as ɵDirectiveDef, + DirectiveDefWithMeta as ɵDirectiveDefWithMeta, PipeDef as ɵPipeDef, + PipeDefWithMeta as ɵPipeDefWithMeta, whenRendered as ɵwhenRendered, i18nApply as ɵi18nApply, i18nExpMapping as ɵi18nExpMapping, @@ -134,7 +136,7 @@ export { export { NgModuleDef as ɵNgModuleDef, - NgModuleDefInternal as ɵNgModuleDefInternal, + NgModuleDefWithMeta as ɵNgModuleDefWithMeta, NgModuleTransitiveScopes as ɵNgModuleTransitiveScopes, } from './metadata/ng_module'; diff --git a/packages/core/src/metadata/ng_module.ts b/packages/core/src/metadata/ng_module.ts index 3f98f5b119..d48bd72a6e 100644 --- a/packages/core/src/metadata/ng_module.ts +++ b/packages/core/src/metadata/ng_module.ts @@ -26,11 +26,7 @@ export interface NgModuleTransitiveScopes { exported: {directives: Set; pipes: Set;}; } -/** - * A version of {@link NgModuleDef} that represents the runtime type shape only, and excludes - * metadata parameters. - */ -export type NgModuleDefInternal = NgModuleDef; +export type NgModuleDefWithMeta = NgModuleDef; /** * Runtime link information for NgModules. @@ -42,7 +38,7 @@ export type NgModuleDefInternal = NgModuleDef; * never create the object directly since the shape of this object * can change between versions. */ -export interface NgModuleDef { +export interface NgModuleDef { /** Token representing the module. Used by DI. */ type: T; diff --git a/packages/core/src/render3/component.ts b/packages/core/src/render3/component.ts index c12bd444fc..a3e32ef482 100644 --- a/packages/core/src/render3/component.ts +++ b/packages/core/src/render3/component.ts @@ -19,7 +19,7 @@ import {queueInitHooks, queueLifecycleHooks} from './hooks'; import {PlayerHandler} from './interfaces/player'; import {CLEAN_PROMISE, baseDirectiveCreate, createLViewData, createTView, detectChangesInternal, enterView, executeInitAndContentHooks, hostElement, leaveView, locateHostElement, setHostBindings, queueHostBindingForCheck,} from './instructions'; -import {ComponentDef, ComponentDefInternal, ComponentType} from './interfaces/definition'; +import {ComponentDef, ComponentType} from './interfaces/definition'; import {LElementNode} from './interfaces/node'; import {RElement, RendererFactory3, domRendererFactory3} from './interfaces/renderer'; import {CONTEXT, INJECTOR, LViewData, LViewFlags, RootContext, RootContextFlags, TVIEW} from './interfaces/view'; @@ -77,7 +77,7 @@ export interface CreateComponentOptions { } /** See CreateComponentOptions.hostFeatures */ -type HostFeature = ((component: T, componentDef: ComponentDef) => void); +type HostFeature = ((component: T, componentDef: ComponentDef) => void); // TODO: A hack to not pull in the NullInjector from @angular/core. export const NULL_INJECTOR: Injector = { @@ -149,7 +149,7 @@ export function renderComponent( * renderComponent() and ViewContainerRef.createComponent(). */ export function createRootComponent( - elementNode: LElementNode, componentDef: ComponentDef, rootView: LViewData, + elementNode: LElementNode, componentDef: ComponentDef, rootView: LViewData, rootContext: RootContext, hostFeatures: HostFeature[] | null): any { // Create directive instance with factory() and store at index 0 in directives array const component = baseDirectiveCreate(0, componentDef.factory() as T, componentDef, elementNode); @@ -188,7 +188,7 @@ export function createRootContext( * renderComponent(AppComponent, {features: [RootLifecycleHooks]}); * ``` */ -export function LifecycleHooksFeature(component: any, def: ComponentDefInternal): void { +export function LifecycleHooksFeature(component: any, def: ComponentDef): void { const rootTView = readPatchedLViewData(component) ![TVIEW]; // Root component is always created at dir index 0 diff --git a/packages/core/src/render3/component_ref.ts b/packages/core/src/render3/component_ref.ts index 365778d6ee..b936f20fa5 100644 --- a/packages/core/src/render3/component_ref.ts +++ b/packages/core/src/render3/component_ref.ts @@ -20,7 +20,7 @@ import {assertComponentType, assertDefined} from './assert'; import {LifecycleHooksFeature, createRootComponent, createRootContext} from './component'; import {getComponentDef} from './definition'; import {adjustBlueprintForNewNode, createLViewData, createNodeAtIndex, createTView, elementCreate, enterView, getTNode, hostElement, locateHostElement, renderEmbeddedTemplate} from './instructions'; -import {ComponentDefInternal, RenderFlags} from './interfaces/definition'; +import {ComponentDef, RenderFlags} from './interfaces/definition'; import {LElementNode, TElementNode, TNode, TNodeType, TViewNode} from './interfaces/node'; import {RElement, RendererFactory3, domRendererFactory3} from './interfaces/renderer'; import {FLAGS, INJECTOR, LViewData, LViewFlags, RootContext, TVIEW} from './interfaces/view'; @@ -88,7 +88,7 @@ export class ComponentFactory extends viewEngine_ComponentFactory { return toRefArray(this.componentDef.outputs); } - constructor(private componentDef: ComponentDefInternal) { + constructor(private componentDef: ComponentDef) { super(); this.componentType = componentDef.type; this.selector = componentDef.selectors[0][0] as string; diff --git a/packages/core/src/render3/definition.ts b/packages/core/src/render3/definition.ts index 2969c44b2a..7513155d19 100644 --- a/packages/core/src/render3/definition.ts +++ b/packages/core/src/render3/definition.ts @@ -10,12 +10,12 @@ import './ng_dev_mode'; import {ChangeDetectionStrategy} from '../change_detection/constants'; import {Provider} from '../di/provider'; -import {NgModuleDef, NgModuleDefInternal} from '../metadata/ng_module'; +import {NgModuleDef} from '../metadata/ng_module'; import {ViewEncapsulation} from '../metadata/view'; import {Type} from '../type'; import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields'; -import {BaseDef, ComponentDefFeature, ComponentDefInternal, ComponentQuery, ComponentTemplate, ComponentType, DirectiveDefFeature, DirectiveDefInternal, DirectiveType, DirectiveTypesOrFactory, PipeDefInternal, PipeType, PipeTypesOrFactory} from './interfaces/definition'; +import {BaseDef, ComponentDef, ComponentDefFeature, ComponentQuery, ComponentTemplate, ComponentType, DirectiveDef, DirectiveDefFeature, DirectiveType, DirectiveTypesOrFactory, PipeDef, PipeType, PipeTypesOrFactory} from './interfaces/definition'; import {CssSelectorList, SelectorFlags} from './interfaces/projection'; export const EMPTY: {} = {}; @@ -280,7 +280,7 @@ export function defineComponent(componentDefinition: { if (animations) { data.animations = animations; } - const def: ComponentDefInternal = { + const def: ComponentDef = { type: type, diPublic: null, consts: componentDefinition.consts, @@ -328,7 +328,7 @@ export function defineComponent(componentDefinition: { } export function extractDirectiveDef(type: DirectiveType& ComponentType): - DirectiveDefInternal|ComponentDefInternal { + DirectiveDef|ComponentDef { const def = getComponentDef(type) || getDirectiveDef(type); if (ngDevMode && !def) { throw new Error(`'${type.name}' is neither 'ComponentType' or 'DirectiveType'.`); @@ -336,7 +336,7 @@ export function extractDirectiveDef(type: DirectiveType& ComponentType return def !; } -export function extractPipeDef(type: PipeType): PipeDefInternal { +export function extractPipeDef(type: PipeType): PipeDef { const def = getPipeDef(type); if (ngDevMode && !def) { throw new Error(`'${type.name}' is not a 'PipeType'.`); @@ -344,8 +344,8 @@ export function extractPipeDef(type: PipeType): PipeDefInternal { return def !; } -export function defineNgModule(def: {type: T} & Partial>): never { - const res: NgModuleDefInternal = { +export function defineNgModule(def: {type: T} & Partial>): never { + const res: NgModuleDef = { type: def.type, bootstrap: def.bootstrap || EMPTY_ARRAY, declarations: def.declarations || EMPTY_ARRAY, @@ -656,7 +656,7 @@ export function definePipe(pipeDef: { /** Whether the pipe is pure. */ pure?: boolean }): never { - return (>{ + return (>{ name: pipeDef.name, factory: pipeDef.factory, pure: pipeDef.pure !== false, @@ -670,18 +670,18 @@ export function definePipe(pipeDef: { * explicit. This would require some sort of migration strategy. */ -export function getComponentDef(type: any): ComponentDefInternal|null { +export function getComponentDef(type: any): ComponentDef|null { return (type as any)[NG_COMPONENT_DEF] || null; } -export function getDirectiveDef(type: any): DirectiveDefInternal|null { +export function getDirectiveDef(type: any): DirectiveDef|null { return (type as any)[NG_DIRECTIVE_DEF] || null; } -export function getPipeDef(type: any): PipeDefInternal|null { +export function getPipeDef(type: any): PipeDef|null { return (type as any)[NG_PIPE_DEF] || null; } -export function getNgModuleDef(type: any): NgModuleDefInternal|null { +export function getNgModuleDef(type: any): NgModuleDef|null { return (type as any)[NG_MODULE_DEF] || null; } diff --git a/packages/core/src/render3/di.ts b/packages/core/src/render3/di.ts index 40a92b489a..5f0b258aa6 100644 --- a/packages/core/src/render3/di.ts +++ b/packages/core/src/render3/di.ts @@ -19,7 +19,7 @@ import {assertDefined} from './assert'; import {getComponentDef, getDirectiveDef, getPipeDef} from './definition'; import {NG_ELEMENT_ID} from './fields'; import {_getViewData, assertPreviousIsParent, getPreviousOrParentTNode, resolveDirective, setEnvironment} from './instructions'; -import {DirectiveDefInternal} from './interfaces/definition'; +import {DirectiveDef} from './interfaces/definition'; import {INJECTOR_SIZE, InjectorLocationFlags, PARENT_INJECTOR, TNODE,} from './interfaces/injector'; import {AttributeMarker, TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeType} from './interfaces/node'; import {isProceduralRenderer} from './interfaces/renderer'; @@ -196,7 +196,7 @@ export function getParentInjectorView(location: number, startView: LViewData): L * @param def The definition of the directive to be made public */ export function diPublicInInjector( - injectorIndex: number, view: LViewData, def: DirectiveDefInternal): void { + injectorIndex: number, view: LViewData, def: DirectiveDef): void { bloomAdd(injectorIndex, view[TVIEW], def.type); } @@ -205,7 +205,7 @@ export function diPublicInInjector( * * @param def The definition of the directive to be made public */ -export function diPublic(def: DirectiveDefInternal): void { +export function diPublic(def: DirectiveDef): void { diPublicInInjector(getOrCreateNodeInjector(), _getViewData(), def); } @@ -399,7 +399,7 @@ function searchMatchesQueuedForCreation(token: any, hostTView: TView): T|null const matches = hostTView.currentMatches; if (matches) { for (let i = 0; i < matches.length; i += 2) { - const def = matches[i] as DirectiveDefInternal; + const def = matches[i] as DirectiveDef; if (def.type === token) { return resolveDirective(def, i + 1, matches, hostTView); } @@ -422,7 +422,7 @@ function searchDirectivesOnInjector( for (let i = start; i < end; i++) { // Get the definition for the directive at this index and, if it is injectable (diPublic), // and matches the given token, return the directive instance. - const directiveDef = defs[i] as DirectiveDefInternal; + const directiveDef = defs[i] as DirectiveDef; if (directiveDef.type === token && directiveDef.diPublic) { return injectorView[DIRECTIVES] ![i]; } diff --git a/packages/core/src/render3/features/inherit_definition_feature.ts b/packages/core/src/render3/features/inherit_definition_feature.ts index 878cf79559..d3dc00db92 100644 --- a/packages/core/src/render3/features/inherit_definition_feature.ts +++ b/packages/core/src/render3/features/inherit_definition_feature.ts @@ -9,22 +9,22 @@ import {Type} from '../../type'; import {fillProperties} from '../../util/property'; import {EMPTY, EMPTY_ARRAY} from '../definition'; -import {ComponentDefInternal, ComponentTemplate, DirectiveDefFeature, DirectiveDefInternal, RenderFlags} from '../interfaces/definition'; +import {ComponentDef, ComponentTemplate, DirectiveDef, DirectiveDefFeature, RenderFlags} from '../interfaces/definition'; /** - * Determines if a definition is a {@link ComponentDefInternal} or a {@link DirectiveDefInternal} + * Determines if a definition is a {@link ComponentDef} or a {@link DirectiveDef} * @param definition The definition to examine */ -function isComponentDef(definition: ComponentDefInternal| DirectiveDefInternal): - definition is ComponentDefInternal { - const def = definition as ComponentDefInternal; +function isComponentDef(definition: ComponentDef| DirectiveDef): + definition is ComponentDef { + const def = definition as ComponentDef; return typeof def.template === 'function'; } function getSuperType(type: Type): Type& - {ngComponentDef?: ComponentDefInternal, ngDirectiveDef?: DirectiveDefInternal} { + {ngComponentDef?: ComponentDef, ngDirectiveDef?: DirectiveDef} { return Object.getPrototypeOf(type.prototype).constructor; } @@ -32,12 +32,11 @@ function getSuperType(type: Type): Type& * Merges the definition from a super class to a sub class. * @param definition The definition that is a SubClass of another directive of component */ -export function InheritDefinitionFeature( - definition: DirectiveDefInternal| ComponentDefInternal): void { +export function InheritDefinitionFeature(definition: DirectiveDef| ComponentDef): void { let superType = getSuperType(definition.type); while (superType) { - let superDef: DirectiveDefInternal|ComponentDefInternal|undefined = undefined; + let superDef: DirectiveDef|ComponentDef|undefined = undefined; if (isComponentDef(definition)) { // Don't use getComponentDef/getDirectiveDef. This logic relies on inheritance. superDef = superType.ngComponentDef || superType.ngDirectiveDef; diff --git a/packages/core/src/render3/features/ng_onchanges_feature.ts b/packages/core/src/render3/features/ng_onchanges_feature.ts index 75b4147f8f..ec5af77315 100644 --- a/packages/core/src/render3/features/ng_onchanges_feature.ts +++ b/packages/core/src/render3/features/ng_onchanges_feature.ts @@ -8,7 +8,7 @@ import {SimpleChange} from '../../change_detection/change_detection_util'; import {OnChanges, SimpleChanges} from '../../metadata/lifecycle_hooks'; -import {DirectiveDefInternal} from '../interfaces/definition'; +import {DirectiveDef} from '../interfaces/definition'; const PRIVATE_PREFIX = '__ngOnChanges_'; @@ -38,7 +38,7 @@ type OnChangesExpando = OnChanges & { * }); * ``` */ -export function NgOnChangesFeature(definition: DirectiveDefInternal): void { +export function NgOnChangesFeature(definition: DirectiveDef): void { const declaredToMinifiedInputs = definition.declaredInputs; const proto = definition.type.prototype; for (const declaredName in declaredToMinifiedInputs) { diff --git a/packages/core/src/render3/features/public_feature.ts b/packages/core/src/render3/features/public_feature.ts index 6ed10af191..dd1925e7a3 100644 --- a/packages/core/src/render3/features/public_feature.ts +++ b/packages/core/src/render3/features/public_feature.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import {diPublic} from '../di'; -import {DirectiveDefInternal} from '../interfaces/definition'; +import {DirectiveDef} from '../interfaces/definition'; /** * This feature publishes the directive (or component) into the DI system, making it visible to @@ -14,6 +14,6 @@ import {DirectiveDefInternal} from '../interfaces/definition'; * * @param definition */ -export function PublicFeature(definition: DirectiveDefInternal) { +export function PublicFeature(definition: DirectiveDef) { definition.diPublic = diPublic; } diff --git a/packages/core/src/render3/hooks.ts b/packages/core/src/render3/hooks.ts index f05f673b58..5b49b24b78 100644 --- a/packages/core/src/render3/hooks.ts +++ b/packages/core/src/render3/hooks.ts @@ -7,7 +7,7 @@ */ import {assertEqual} from './assert'; -import {DirectiveDefInternal} from './interfaces/definition'; +import {DirectiveDef} from './interfaces/definition'; import {TNodeFlags} from './interfaces/node'; import {DIRECTIVES, FLAGS, HookData, LViewData, LViewFlags, TView} from './interfaces/view'; @@ -52,7 +52,7 @@ export function queueLifecycleHooks(flags: number, tView: TView): void { // directiveCreate) so we can preserve the current hook order. Content, view, and destroy // hooks for projected components and directives must be called *before* their hosts. for (let i = start; i < end; i++) { - const def: DirectiveDefInternal = tView.directives ![i]; + const def: DirectiveDef = tView.directives ![i]; queueContentHooks(def, tView, i); queueViewHooks(def, tView, i); queueDestroyHooks(def, tView, i); @@ -61,7 +61,7 @@ export function queueLifecycleHooks(flags: number, tView: TView): void { } /** Queues afterContentInit and afterContentChecked hooks on TView */ -function queueContentHooks(def: DirectiveDefInternal, tView: TView, i: number): void { +function queueContentHooks(def: DirectiveDef, tView: TView, i: number): void { if (def.afterContentInit) { (tView.contentHooks || (tView.contentHooks = [])).push(i, def.afterContentInit); } @@ -73,7 +73,7 @@ function queueContentHooks(def: DirectiveDefInternal, tView: TView, i: numb } /** Queues afterViewInit and afterViewChecked hooks on TView */ -function queueViewHooks(def: DirectiveDefInternal, tView: TView, i: number): void { +function queueViewHooks(def: DirectiveDef, tView: TView, i: number): void { if (def.afterViewInit) { (tView.viewHooks || (tView.viewHooks = [])).push(i, def.afterViewInit); } @@ -85,7 +85,7 @@ function queueViewHooks(def: DirectiveDefInternal, tView: TView, i: number) } /** Queues onDestroy hooks on TView */ -function queueDestroyHooks(def: DirectiveDefInternal, tView: TView, i: number): void { +function queueDestroyHooks(def: DirectiveDef, tView: TView, i: number): void { if (def.onDestroy != null) { (tView.destroyHooks || (tView.destroyHooks = [])).push(i, def.onDestroy); } diff --git a/packages/core/src/render3/index.ts b/packages/core/src/render3/index.ts index 28032c91f2..d828d69e12 100644 --- a/packages/core/src/render3/index.ts +++ b/packages/core/src/render3/index.ts @@ -11,7 +11,7 @@ import {defineBase, defineComponent, defineDirective, defineNgModule, definePipe import {InheritDefinitionFeature} from './features/inherit_definition_feature'; import {NgOnChangesFeature} from './features/ng_onchanges_feature'; import {PublicFeature} from './features/public_feature'; -import {BaseDef, ComponentDef, ComponentDefInternal, ComponentTemplate, ComponentType, DirectiveDef, DirectiveDefFlags, DirectiveDefInternal, DirectiveType, PipeDef} from './interfaces/definition'; +import {BaseDef, ComponentDef, ComponentDefWithMeta, ComponentTemplate, ComponentType, DirectiveDef, DirectiveDefFlags, DirectiveDefWithMeta, DirectiveType, PipeDef, PipeDefWithMeta} from './interfaces/definition'; export {ComponentFactory, ComponentFactoryResolver, ComponentRef, WRAP_RENDERER_FACTORY2, injectComponentFactoryResolver} from './component_ref'; export {directiveInject, getFactoryOf, getInheritedFactory, injectAttribute, injectRenderer2} from './di'; @@ -149,17 +149,18 @@ export {templateRefExtractor} from './view_engine_compatibility_prebound'; export { BaseDef, ComponentDef, - ComponentDefInternal, + ComponentDefWithMeta, ComponentTemplate, ComponentType, DirectiveDef, DirectiveDefFlags, - DirectiveDefInternal, + DirectiveDefWithMeta, DirectiveType, NgOnChangesFeature, InheritDefinitionFeature, PublicFeature, PipeDef, + PipeDefWithMeta, LifecycleHooksFeature, defineComponent, defineDirective, diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index 4bb658b699..dd2a835f38 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -18,7 +18,7 @@ import {getRootView} from './discovery_utils'; import {throwCyclicDependencyError, throwErrorIfNoChangesMode, throwMultipleComponentError} from './errors'; import {executeHooks, executeInitHooks, queueInitHooks, queueLifecycleHooks} from './hooks'; import {ACTIVE_INDEX, LContainer, RENDER_PARENT, VIEWS} from './interfaces/container'; -import {ComponentDefInternal, ComponentQuery, ComponentTemplate, DirectiveDefInternal, DirectiveDefListOrFactory, InitialStylingFlags, PipeDefListOrFactory, RenderFlags} from './interfaces/definition'; +import {ComponentDef, ComponentQuery, ComponentTemplate, DirectiveDef, DirectiveDefListOrFactory, InitialStylingFlags, PipeDefListOrFactory, RenderFlags} from './interfaces/definition'; import {AttributeMarker, InitialInputData, InitialInputs, LContainerNode, LElementContainerNode, LElementNode, LNode, LProjectionNode, LTextNode, LViewNode, LocalRefExtractor, PropertyAliasValue, PropertyAliases, TAttributes, TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeType, TProjectionNode, TViewNode} from './interfaces/node'; import {CssSelectorList, NG_PROJECT_AS_ATTR_NAME} from './interfaces/projection'; import {LQueries} from './interfaces/query'; @@ -363,7 +363,7 @@ export function setHostBindings(bindings: number[] | null): void { const defs = tView.directives !; for (let i = 0; i < bindings.length; i += 2) { const dirIndex = bindings[i]; - const def = defs[dirIndex] as DirectiveDefInternal; + const def = defs[dirIndex] as DirectiveDef; if (firstTemplatePass) { for (let i = 0; i < def.hostVars; i++) { tView.blueprint.push(NO_CHANGE); @@ -906,7 +906,7 @@ function cacheMatchingDirectivesForNode( const matches = tView.currentMatches = findDirectiveMatches(tNode); if (matches) { for (let i = 0; i < matches.length; i += 2) { - const def = matches[i] as DirectiveDefInternal; + const def = matches[i] as DirectiveDef; const valueIndex = i + 1; resolveDirective(def, valueIndex, matches, tView); saveNameToExportMap(matches[valueIndex] as number, def, exportsMap); @@ -924,9 +924,9 @@ function findDirectiveMatches(tNode: TNode): CurrentMatchesList|null { const def = registry[i]; if (isNodeMatchingSelectorList(tNode, def.selectors !)) { matches || (matches = []); - if ((def as ComponentDefInternal).template) { + if ((def as ComponentDef).template) { if (tNode.flags & TNodeFlags.isComponent) throwMultipleComponentError(tNode); - addComponentLogic(def as ComponentDefInternal); + addComponentLogic(def as ComponentDef); tNode.flags = TNodeFlags.isComponent; // The component is always stored first with directives after. @@ -942,8 +942,7 @@ function findDirectiveMatches(tNode: TNode): CurrentMatchesList|null { } export function resolveDirective( - def: DirectiveDefInternal, valueIndex: number, matches: CurrentMatchesList, - tView: TView): any { + def: DirectiveDef, valueIndex: number, matches: CurrentMatchesList, tView: TView): any { if (matches[valueIndex] === null) { matches[valueIndex] = CIRCULAR; const instance = def.factory(); @@ -993,12 +992,12 @@ function instantiateDirectivesDirectly() { const tDirectives = tView.directives !; for (let i = start; i < end; i++) { - const def: DirectiveDefInternal = tDirectives[i]; + const def: DirectiveDef = tDirectives[i]; // Component view must be set on node before the factory is created so // ChangeDetectorRefs have a way to store component view on creation. - if ((def as ComponentDefInternal).template) { - addComponentLogic(def as ComponentDefInternal); + if ((def as ComponentDef).template) { + addComponentLogic(def as ComponentDef); } directiveCreate(i, def.factory(), def); } @@ -1027,11 +1026,11 @@ function cacheMatchingLocalNames( * to their directive instances. */ function saveNameToExportMap( - index: number, def: DirectiveDefInternal| ComponentDefInternal, + index: number, def: DirectiveDef| ComponentDef, exportsMap: {[key: string]: number} | null) { if (exportsMap) { if (def.exportAs) exportsMap[def.exportAs] = index; - if ((def as ComponentDefInternal).template) exportsMap[''] = index; + if ((def as ComponentDef).template) exportsMap[''] = index; } } @@ -1212,7 +1211,7 @@ export function locateHostElement( * @returns LElementNode created */ export function hostElement( - tag: string, rNode: RElement | null, def: ComponentDefInternal, + tag: string, rNode: RElement | null, def: ComponentDef, sanitizer?: Sanitizer | null): LElementNode { resetComponentState(); const tNode = createNodeAtIndex( @@ -1522,7 +1521,7 @@ function generatePropertyAliases( const defs = tView.directives !; for (let i = start; i < end; i++) { - const directiveDef = defs[i] as DirectiveDefInternal; + const directiveDef = defs[i] as DirectiveDef; const propertyAliasMap: {[publicName: string]: string} = isInput ? directiveDef.inputs : directiveDef.outputs; for (let publicName in propertyAliasMap) { @@ -1763,12 +1762,11 @@ export function textBinding(index: number, value: T | NO_CHANGE): void { * @param directiveDef DirectiveDef object which contains information about the template. */ export function directiveCreate( - directiveDefIdx: number, directive: T, - directiveDef: DirectiveDefInternal| ComponentDefInternal): T { + directiveDefIdx: number, directive: T, directiveDef: DirectiveDef| ComponentDef): T { const hostNode = getLNode(previousOrParentTNode, viewData); const instance = baseDirectiveCreate(directiveDefIdx, directive, directiveDef, hostNode); - if ((directiveDef as ComponentDefInternal).template) { + if ((directiveDef as ComponentDef).template) { hostNode.data ![CONTEXT] = directive; } @@ -1792,7 +1790,7 @@ export function directiveCreate( return instance; } -function addComponentLogic(def: ComponentDefInternal): void { +function addComponentLogic(def: ComponentDef): void { const hostNode = getLNode(previousOrParentTNode, viewData); const tView = getOrCreateTView( @@ -1821,7 +1819,7 @@ function addComponentLogic(def: ComponentDefInternal): void { * current Angular. Example: local refs and inputs on root component. */ export function baseDirectiveCreate( - index: number, directive: T, directiveDef: DirectiveDefInternal| ComponentDefInternal, + index: number, directive: T, directiveDef: DirectiveDef| ComponentDef, hostNode: LNode): T { ngDevMode && assertEqual( viewData[BINDING_INDEX], tView.bindingStartIndex, diff --git a/packages/core/src/render3/interfaces/definition.ts b/packages/core/src/render3/interfaces/definition.ts index af19a7c161..91d7ec568a 100644 --- a/packages/core/src/render3/interfaces/definition.ts +++ b/packages/core/src/render3/interfaces/definition.ts @@ -59,11 +59,9 @@ export const enum DirectiveDefFlags {ContentQuery = 0b10} */ export interface PipeType extends Type { ngPipeDef: never; } -/** - * A version of {@link DirectiveDef} that represents the runtime type shape only, and excludes - * metadata parameters. - */ -export type DirectiveDefInternal = DirectiveDef; +export type DirectiveDefWithMeta< + T, Selector extends string, ExportAs extends string, InputMap extends{[key: string]: string}, + OutputMap extends{[key: string]: string}, QueryFields extends string[]> = DirectiveDef; /** * Runtime information for classes that are inherited by components or directives @@ -110,12 +108,12 @@ export interface BaseDef { * * See: {@link defineDirective} */ -export interface DirectiveDef extends BaseDef { +export interface DirectiveDef extends BaseDef { /** Token representing the directive. Used by DI. */ type: Type; /** Function that makes a directive public to the DI system. */ - diPublic: ((def: DirectiveDef) => void)|null; + diPublic: ((def: DirectiveDef) => void)|null; /** The selectors that will be used to match nodes to this directive. */ selectors: CssSelectorList; @@ -172,11 +170,9 @@ export interface DirectiveDef extends BaseDef { features: DirectiveDefFeature[]|null; } -/** - * A version of {@link ComponentDef} that represents the runtime type shape only, and excludes - * metadata parameters. - */ -export type ComponentDefInternal = ComponentDef; +export type ComponentDefWithMeta< + T, Selector extends String, ExportAs extends string, InputMap extends{[key: string]: string}, + OutputMap extends{[key: string]: string}, QueryFields extends string[]> = ComponentDef; /** * Runtime link information for Components. @@ -190,7 +186,7 @@ export type ComponentDefInternal = ComponentDef; * * See: {@link defineComponent} */ -export interface ComponentDef extends DirectiveDef { +export interface ComponentDef extends DirectiveDef { /** * Runtime unique component ID. */ @@ -289,13 +285,13 @@ export interface ComponentDef extends DirectiveDef { +export interface PipeDef { /** * Pipe name. * * Used to resolve pipe in templates. */ - name: S; + name: string; /** * Factory function used to create a new pipe instance. @@ -314,10 +310,10 @@ export interface PipeDef { onDestroy: (() => void)|null; } -export type PipeDefInternal = PipeDef; +export type PipeDefWithMeta = PipeDef; -export type DirectiveDefFeature = (directiveDef: DirectiveDef) => void; -export type ComponentDefFeature = (componentDef: ComponentDef) => void; +export type DirectiveDefFeature = (directiveDef: DirectiveDef) => void; +export type ComponentDefFeature = (componentDef: ComponentDef) => void; /** * Type used for directiveDefs on component definition. @@ -326,12 +322,12 @@ export type ComponentDefFeature = (componentDef: ComponentDef) => */ export type DirectiveDefListOrFactory = (() => DirectiveDefList) | DirectiveDefList; -export type DirectiveDefList = (DirectiveDef| ComponentDef)[]; +export type DirectiveDefList = (DirectiveDef| ComponentDef)[]; export type DirectiveTypesOrFactory = (() => DirectiveTypeList) | DirectiveTypeList; export type DirectiveTypeList = - (DirectiveDef| ComponentDef| + (DirectiveDef| ComponentDef| Type/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[]; /** @@ -341,13 +337,12 @@ export type DirectiveTypeList = */ export type PipeDefListOrFactory = (() => PipeDefList) | PipeDefList; -export type PipeDefList = PipeDefInternal[]; +export type PipeDefList = PipeDef[]; export type PipeTypesOrFactory = (() => DirectiveTypeList) | DirectiveTypeList; export type PipeTypeList = - (PipeDefInternal| - Type/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[]; + (PipeDef| Type/* Type as workaround for: Microsoft/TypeScript/issues/4881 */)[]; // Note: This hack is necessary so we don't erroneously get a circular dependency diff --git a/packages/core/src/render3/interfaces/view.ts b/packages/core/src/render3/interfaces/view.ts index 8d1719ed87..3c3409f8d0 100644 --- a/packages/core/src/render3/interfaces/view.ts +++ b/packages/core/src/render3/interfaces/view.ts @@ -12,7 +12,7 @@ import {Sanitizer} from '../../sanitization/security'; import {PlayerHandler} from '../interfaces/player'; import {LContainer} from './container'; -import {ComponentQuery, ComponentTemplate, DirectiveDefInternal, DirectiveDefList, PipeDefInternal, PipeDefList} from './definition'; +import {ComponentQuery, ComponentTemplate, DirectiveDef, DirectiveDefList, PipeDef, PipeDefList} from './definition'; import {LElementNode, LViewNode, TElementNode, TNode, TViewNode} from './node'; import {LQueries} from './query'; import {Renderer3} from './renderer'; @@ -558,10 +558,10 @@ export type HookData = (number | (() => void))[]; * * Injector bloom filters are also stored here. */ -export type TData = (TNode | PipeDefInternal| number | null)[]; +export type TData = (TNode | PipeDef| number | null)[]; /** Type for TView.currentMatches */ -export type CurrentMatchesList = [DirectiveDefInternal, (string | number | null)]; +export type CurrentMatchesList = [DirectiveDef, (string | number | null)]; // Note: This hack is necessary so we don't erroneously get a circular dependency // failure based on types. diff --git a/packages/core/src/render3/jit/module.ts b/packages/core/src/render3/jit/module.ts index d5dad0ee7b..a427389cf1 100644 --- a/packages/core/src/render3/jit/module.ts +++ b/packages/core/src/render3/jit/module.ts @@ -8,11 +8,11 @@ import {Expression, R3InjectorMetadata, R3NgModuleMetadata, R3Reference, WrappedNodeExpr, compileInjector, compileNgModule as compileR3NgModule, jitExpression} from '@angular/compiler'; -import {ModuleWithProviders, NgModule, NgModuleDefInternal, NgModuleTransitiveScopes} from '../../metadata/ng_module'; +import {ModuleWithProviders, NgModule, NgModuleDef, NgModuleTransitiveScopes} from '../../metadata/ng_module'; import {Type} from '../../type'; import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition'; import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_INJECTOR_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from '../fields'; -import {ComponentDefInternal} from '../interfaces/definition'; +import {ComponentDef} from '../interfaces/definition'; import {angularCoreEnv} from './environment'; import {reflectDependencies} from './util'; @@ -100,7 +100,7 @@ function setScopeOnDeclaredComponents(moduleType: Type, ngModule: NgModule) declarations.forEach(declaration => { if (declaration.hasOwnProperty(NG_COMPONENT_DEF)) { // An `ngComponentDef` field exists - go ahead and patch the component directly. - const component = declaration as Type& {ngComponentDef: ComponentDefInternal}; + const component = declaration as Type& {ngComponentDef: ComponentDef}; const componentDef = getComponentDef(component) !; patchComponentDefWithScope(componentDef, transitiveScopes); } else if ( @@ -116,7 +116,7 @@ function setScopeOnDeclaredComponents(moduleType: Type, ngModule: NgModule) * a given module. */ export function patchComponentDefWithScope( - componentDef: ComponentDefInternal, transitiveScopes: NgModuleTransitiveScopes) { + componentDef: ComponentDef, transitiveScopes: NgModuleTransitiveScopes) { componentDef.directiveDefs = () => Array.from(transitiveScopes.compilation.directives) .map(dir => getDirectiveDef(dir) || getComponentDef(dir) !) .filter(def => !!def); @@ -168,7 +168,7 @@ export function transitiveScopesFor(moduleType: Type): NgModuleTransitiveS def.imports.forEach((imported: Type) => { const importedTyped = imported as Type& { // If imported is an @NgModule: - ngModuleDef?: NgModuleDefInternal; + ngModuleDef?: NgModuleDef; }; if (!isNgModule(importedTyped)) { @@ -187,7 +187,7 @@ export function transitiveScopesFor(moduleType: Type): NgModuleTransitiveS // Components, Directives, NgModules, and Pipes can all be exported. ngComponentDef?: any; ngDirectiveDef?: any; - ngModuleDef?: NgModuleDefInternal; + ngModuleDef?: NgModuleDef; ngPipeDef?: any; }; @@ -248,6 +248,6 @@ function isModuleWithProviders(value: any): value is ModuleWithProviders<{}> { return (value as{ngModule?: any}).ngModule !== undefined; } -function isNgModule(value: Type): value is Type&{ngModuleDef: NgModuleDefInternal} { +function isNgModule(value: Type): value is Type&{ngModuleDef: NgModuleDef} { return !!getNgModuleDef(value); } diff --git a/packages/core/src/render3/ng_module_ref.ts b/packages/core/src/render3/ng_module_ref.ts index a07b2ddd59..51f5810249 100644 --- a/packages/core/src/render3/ng_module_ref.ts +++ b/packages/core/src/render3/ng_module_ref.ts @@ -11,14 +11,14 @@ import {StaticProvider} from '../di/provider'; import {createInjector} from '../di/r3_injector'; import {ComponentFactoryResolver as viewEngine_ComponentFactoryResolver} from '../linker/component_factory_resolver'; import {InternalNgModuleRef, NgModuleFactory as viewEngine_NgModuleFactory, NgModuleRef as viewEngine_NgModuleRef} from '../linker/ng_module_factory'; -import {NgModuleDefInternal} from '../metadata/ng_module'; +import {NgModuleDef} from '../metadata/ng_module'; import {Type} from '../type'; import {stringify} from '../util'; import {assertDefined} from './assert'; import {ComponentFactoryResolver} from './component_ref'; import {getNgModuleDef} from './definition'; -export interface NgModuleType { ngModuleDef: NgModuleDefInternal; } +export interface NgModuleType { ngModuleDef: NgModuleDef; } export const COMPONENT_FACTORY_RESOLVER: StaticProvider = { provide: viewEngine_ComponentFactoryResolver, diff --git a/packages/core/src/render3/pipe.ts b/packages/core/src/render3/pipe.ts index b8af03f03d..0ac27f9f5a 100644 --- a/packages/core/src/render3/pipe.ts +++ b/packages/core/src/render3/pipe.ts @@ -9,7 +9,7 @@ import {PipeTransform} from '../change_detection/pipe_transform'; import {getTView, load, store} from './instructions'; -import {PipeDefInternal, PipeDefList} from './interfaces/definition'; +import {PipeDef, PipeDefList} from './interfaces/definition'; import {HEADER_OFFSET} from './interfaces/view'; import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunctionV} from './pure_function'; @@ -22,7 +22,7 @@ import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunction */ export function pipe(index: number, pipeName: string): any { const tView = getTView(); - let pipeDef: PipeDefInternal; + let pipeDef: PipeDef; const adjustedIndex = index + HEADER_OFFSET; if (tView.firstTemplatePass) { @@ -33,7 +33,7 @@ export function pipe(index: number, pipeName: string): any { ])).push(adjustedIndex, pipeDef.onDestroy); } } else { - pipeDef = tView.data[adjustedIndex] as PipeDefInternal; + pipeDef = tView.data[adjustedIndex] as PipeDef; } const pipeInstance = pipeDef.factory(); @@ -49,7 +49,7 @@ export function pipe(index: number, pipeName: string): any { * @param registry Full list of available pipes * @returns Matching PipeDef */ -function getPipeDef(name: string, registry: PipeDefList | null): PipeDefInternal { +function getPipeDef(name: string, registry: PipeDefList | null): PipeDef { if (registry) { for (let i = 0; i < registry.length; i++) { const pipeDef = registry[i]; @@ -151,5 +151,5 @@ export function pipeBindV(index: number, slotOffset: number, values: any[]): any } function isPure(index: number): boolean { - return (>getTView().data[index + HEADER_OFFSET]).pure; + return (>getTView().data[index + HEADER_OFFSET]).pure; } diff --git a/packages/core/src/render3/query.ts b/packages/core/src/render3/query.ts index 71d2379344..647e0196ea 100644 --- a/packages/core/src/render3/query.ts +++ b/packages/core/src/render3/query.ts @@ -20,7 +20,7 @@ import {getSymbolIterator} from '../util'; import {assertDefined, assertEqual} from './assert'; import {NG_ELEMENT_ID} from './fields'; import {_getViewData, assertPreviousIsParent, getOrCreateCurrentQueries, store, storeCleanupWithContext} from './instructions'; -import {DirectiveDefInternal, unusedValueExportToPlacateAjd as unused1} from './interfaces/definition'; +import {DirectiveDef, unusedValueExportToPlacateAjd as unused1} from './interfaces/definition'; import {unusedValueExportToPlacateAjd as unused2} from './interfaces/injector'; import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeType, unusedValueExportToPlacateAjd as unused3} from './interfaces/node'; import {LQueries, QueryReadType, unusedValueExportToPlacateAjd as unused4} from './interfaces/query'; @@ -258,7 +258,7 @@ function getIdxOfMatchingDirective(tNode: TNode, currentView: LViewData, type: T const start = flags >> TNodeFlags.DirectiveStartingIndexShift; const end = start + count; for (let i = start; i < end; i++) { - const def = defs[i] as DirectiveDefInternal; + const def = defs[i] as DirectiveDef; if (def.type === type && def.diPublic) { return i; } diff --git a/packages/core/test/render3/Inherit_definition_feature_spec.ts b/packages/core/test/render3/Inherit_definition_feature_spec.ts index 29f234e7ed..39be343916 100644 --- a/packages/core/test/render3/Inherit_definition_feature_spec.ts +++ b/packages/core/test/render3/Inherit_definition_feature_spec.ts @@ -9,7 +9,7 @@ import {EventEmitter, Output} from '../../src/core'; import {EMPTY} from '../../src/render3/definition'; import {InheritDefinitionFeature} from '../../src/render3/features/inherit_definition_feature'; -import {ComponentDefInternal, DirectiveDefInternal, RenderFlags, defineBase, defineComponent, defineDirective} from '../../src/render3/index'; +import {ComponentDef, DirectiveDef, RenderFlags, defineBase, defineComponent, defineDirective} from '../../src/render3/index'; describe('InheritDefinitionFeature', () => { it('should inherit lifecycle hooks', () => { @@ -36,7 +36,7 @@ describe('InheritDefinitionFeature', () => { }); } - const finalDef = SubDirective.ngDirectiveDef as DirectiveDefInternal; + const finalDef = SubDirective.ngDirectiveDef as DirectiveDef; expect(finalDef.onInit).toBe(SuperDirective.prototype.ngOnInit); @@ -75,7 +75,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = SubDirective.ngDirectiveDef as DirectiveDefInternal; + const subDef = SubDirective.ngDirectiveDef as DirectiveDef; expect(subDef.inputs).toEqual({ foo: 'superFoo', @@ -118,7 +118,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = SubDirective.ngDirectiveDef as DirectiveDefInternal; + const subDef = SubDirective.ngDirectiveDef as DirectiveDef; expect(subDef.outputs).toEqual({ foo: 'superFoo', @@ -152,7 +152,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = SubDirective.ngDirectiveDef as DirectiveDefInternal; + const subDef = SubDirective.ngDirectiveDef as DirectiveDef; expect(subDef.inputs).toEqual({ testIn: 'testIn', @@ -216,7 +216,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = Class1.ngDirectiveDef as DirectiveDefInternal; + const subDef = Class1.ngDirectiveDef as DirectiveDef; expect(subDef.inputs).toEqual({ input1: 'input1', @@ -288,7 +288,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = Class1.ngDirectiveDef as DirectiveDefInternal; + const subDef = Class1.ngDirectiveDef as DirectiveDef; expect(subDef.outputs).toEqual({ alias1: 'output1', @@ -325,7 +325,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = SubDirective.ngDirectiveDef as DirectiveDefInternal; + const subDef = SubDirective.ngDirectiveDef as DirectiveDef; subDef.hostBindings !(1, 2); @@ -364,7 +364,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = SubComponent.ngComponentDef as ComponentDefInternal; + const subDef = SubComponent.ngComponentDef as ComponentDef; const context = {foo: 'bar'}; @@ -395,7 +395,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = SubDirective.ngDirectiveDef as DirectiveDefInternal; + const subDef = SubDirective.ngDirectiveDef as DirectiveDef; subDef.contentQueries !(); @@ -428,7 +428,7 @@ describe('InheritDefinitionFeature', () => { }); } - const subDef = SubDirective.ngDirectiveDef as DirectiveDefInternal; + const subDef = SubDirective.ngDirectiveDef as DirectiveDef; subDef.contentQueriesRefresh !(1, 2); @@ -487,8 +487,8 @@ describe('InheritDefinitionFeature', () => { }); } - const superDef = SuperDirective.ngDirectiveDef as DirectiveDefInternal; - const subDef = SubDirective.ngDirectiveDef as DirectiveDefInternal; + const superDef = SuperDirective.ngDirectiveDef as DirectiveDef; + const subDef = SubDirective.ngDirectiveDef as DirectiveDef; expect(log).toEqual([ 'super1', diff --git a/packages/core/test/render3/compiler_canonical/component_directives_spec.ts b/packages/core/test/render3/compiler_canonical/component_directives_spec.ts index 7d0dfdac7a..c6ce150465 100644 --- a/packages/core/test/render3/compiler_canonical/component_directives_spec.ts +++ b/packages/core/test/render3/compiler_canonical/component_directives_spec.ts @@ -8,7 +8,7 @@ import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ContentChildren, Directive, HostBinding, HostListener, Injectable, Input, NgModule, OnDestroy, Optional, Pipe, PipeTransform, QueryList, SimpleChanges, TemplateRef, ViewChild, ViewChildren, ViewContainerRef} from '../../../src/core'; import * as $r3$ from '../../../src/core_render3_private_export'; -import {ComponentDefInternal} from '../../../src/render3/interfaces/definition'; +import {ComponentDef} from '../../../src/render3/interfaces/definition'; import {renderComponent, toHtml} from '../render_util'; @@ -82,9 +82,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyComponent.ngComponentDef as ComponentDefInternal).directiveDefs = [ - (ChildComponent.ngComponentDef as ComponentDefInternal), SomeDirective.ngDirectiveDef - ]; + (MyComponent.ngComponentDef as ComponentDef).directiveDefs = + [(ChildComponent.ngComponentDef as ComponentDef), SomeDirective.ngDirectiveDef]; // /NON-NORMATIVE expect(renderComp(MyComponent)).toEqual('child-view!'); @@ -136,8 +135,7 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [HostBindingDir.ngDirectiveDef]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = [HostBindingDir.ngDirectiveDef]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`
`); @@ -191,8 +189,7 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [HostListenerDir.ngDirectiveDef]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = [HostListenerDir.ngDirectiveDef]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(``); @@ -238,8 +235,7 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [HostAttributeDir.ngDirectiveDef]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = [HostAttributeDir.ngDirectiveDef]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`
`); @@ -291,8 +287,7 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [HostBindingDir.ngDirectiveDef]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = [HostBindingDir.ngDirectiveDef]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`
`); @@ -361,8 +356,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [(MyComp.ngComponentDef as ComponentDefInternal)]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = + [(MyComp.ngComponentDef as ComponentDef)]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`some name`); @@ -495,8 +490,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [(MyArrayComp.ngComponentDef as ComponentDefInternal)]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = + [(MyArrayComp.ngComponentDef as ComponentDef)]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`Nancy Bess`); @@ -542,8 +537,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [(MyArrayComp.ngComponentDef as ComponentDefInternal)]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = + [(MyArrayComp.ngComponentDef as ComponentDef)]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`NANCY Bess`); @@ -612,8 +607,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [(MyComp.ngComponentDef as ComponentDefInternal)]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = + [(MyComp.ngComponentDef as ComponentDef)]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`3`); @@ -657,8 +652,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [(MyArrayComp.ngComponentDef as ComponentDefInternal)]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = + [(MyArrayComp.ngComponentDef as ComponentDef)]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`Nancy Bess`); @@ -774,8 +769,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [(MyComp.ngComponentDef as ComponentDefInternal)]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = + [(MyComp.ngComponentDef as ComponentDef)]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`start-abcde-middle-fghi-end`); @@ -854,8 +849,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [(ObjectComp.ngComponentDef as ComponentDefInternal)]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = + [(ObjectComp.ngComponentDef as ComponentDef)]; // /NON-NORMATIVE expect(renderComp(MyApp)).toEqual(`

500

slide

`); @@ -948,8 +943,8 @@ describe('components & directives', () => { } // NON-NORMATIVE (done by defineNgModule) - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = - [(NestedComp.ngComponentDef as ComponentDefInternal)]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = + [(NestedComp.ngComponentDef as ComponentDef)]; // /NON-NORMATIVE expect(renderComp(MyApp)) diff --git a/packages/core/test/render3/compiler_canonical/elements_spec.ts b/packages/core/test/render3/compiler_canonical/elements_spec.ts index 55ddca2166..a95809dfda 100644 --- a/packages/core/test/render3/compiler_canonical/elements_spec.ts +++ b/packages/core/test/render3/compiler_canonical/elements_spec.ts @@ -9,7 +9,7 @@ import {Component} from '../../../src/core'; import * as $r3$ from '../../../src/core_render3_private_export'; import {AttributeMarker} from '../../../src/render3'; -import {ComponentDefInternal, InitialStylingFlags} from '../../../src/render3/interfaces/definition'; +import {ComponentDef, InitialStylingFlags} from '../../../src/render3/interfaces/definition'; import {ComponentFixture, renderComponent, toHtml} from '../render_util'; @@ -107,8 +107,7 @@ describe('elements', () => { } // NON-NORMATIVE - (LocalRefComp.ngComponentDef as ComponentDefInternal).directiveDefs = - () => [Dir.ngDirectiveDef]; + (LocalRefComp.ngComponentDef as ComponentDef).directiveDefs = () => [Dir.ngDirectiveDef]; // /NON-NORMATIVE const fixture = new ComponentFixture(LocalRefComp); diff --git a/packages/core/test/render3/compiler_canonical/life_cycle_spec.ts b/packages/core/test/render3/compiler_canonical/life_cycle_spec.ts index a60d052dd2..b669bcc3d4 100644 --- a/packages/core/test/render3/compiler_canonical/life_cycle_spec.ts +++ b/packages/core/test/render3/compiler_canonical/life_cycle_spec.ts @@ -8,7 +8,7 @@ import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ContentChildren, Directive, HostBinding, HostListener, Injectable, Input, NgModule, OnDestroy, Optional, Pipe, PipeTransform, QueryList, SimpleChanges, TemplateRef, ViewChild, ViewChildren, ViewContainerRef} from '../../../src/core'; import * as $r3$ from '../../../src/core_render3_private_export'; -import {ComponentDefInternal} from '../../../src/render3/interfaces/definition'; +import {ComponentDef} from '../../../src/render3/interfaces/definition'; import {renderComponent, toHtml} from '../render_util'; @@ -88,8 +88,7 @@ describe('lifecycle hooks', () => { } // NON-NORMATIVE - (SimpleLayout.ngComponentDef as ComponentDefInternal).directiveDefs = - [LifecycleComp.ngComponentDef]; + (SimpleLayout.ngComponentDef as ComponentDef).directiveDefs = [LifecycleComp.ngComponentDef]; // /NON-NORMATIVE it('should gen hooks with a few simple components', () => { diff --git a/packages/core/test/render3/compiler_canonical/pipes_spec.ts b/packages/core/test/render3/compiler_canonical/pipes_spec.ts index 8819a564c3..7e06055cef 100644 --- a/packages/core/test/render3/compiler_canonical/pipes_spec.ts +++ b/packages/core/test/render3/compiler_canonical/pipes_spec.ts @@ -8,7 +8,7 @@ import {Component, Directive, Input, OnDestroy, Pipe, PipeTransform, TemplateRef, ViewContainerRef} from '../../../src/core'; import * as $r3$ from '../../../src/core_render3_private_export'; -import {ComponentDefInternal} from '../../../src/render3/interfaces/definition'; +import {ComponentDef} from '../../../src/render3/interfaces/definition'; import {containerEl, renderComponent, toHtml} from '../render_util'; @@ -105,7 +105,7 @@ describe('pipes', () => { } // NON-NORMATIVE - (MyApp.ngComponentDef as ComponentDefInternal).pipeDefs = + (MyApp.ngComponentDef as ComponentDef).pipeDefs = () => [MyPurePipe.ngPipeDef, MyPipe.ngPipeDef]; // /NON-NORMATIVE @@ -205,8 +205,8 @@ describe('pipes', () => { } // NON-NORMATIVE - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = [OneTimeIf.ngDirectiveDef]; - (MyApp.ngComponentDef as ComponentDefInternal).pipeDefs = [MyPurePipe.ngPipeDef]; + (MyApp.ngComponentDef as ComponentDef).directiveDefs = [OneTimeIf.ngDirectiveDef]; + (MyApp.ngComponentDef as ComponentDef).pipeDefs = [MyPurePipe.ngPipeDef]; // /NON-NORMATIVE let myApp: MyApp = renderComponent(MyApp); diff --git a/packages/core/test/render3/compiler_canonical/query_spec.ts b/packages/core/test/render3/compiler_canonical/query_spec.ts index 76c830d797..8a4df8eb63 100644 --- a/packages/core/test/render3/compiler_canonical/query_spec.ts +++ b/packages/core/test/render3/compiler_canonical/query_spec.ts @@ -8,7 +8,7 @@ import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ContentChildren, Directive, HostBinding, HostListener, Injectable, Input, NgModule, OnDestroy, Optional, Pipe, PipeTransform, QueryList, SimpleChanges, TemplateRef, ViewChild, ViewChildren, ViewContainerRef} from '../../../src/core'; import * as $r3$ from '../../../src/core_render3_private_export'; -import {ComponentDefInternal} from '../../../src/render3/interfaces/definition'; +import {ComponentDef} from '../../../src/render3/interfaces/definition'; import {renderComponent, toHtml} from '../render_util'; @@ -80,7 +80,7 @@ describe('queries', () => { } // NON-NORMATIVE - (ViewQueryComponent.ngComponentDef as ComponentDefInternal).directiveDefs = + (ViewQueryComponent.ngComponentDef as ComponentDef).directiveDefs = [SomeDirective.ngDirectiveDef]; // /NON-NORMATIVE @@ -171,7 +171,7 @@ describe('queries', () => { } // NON-NORMATIVE - (MyApp.ngComponentDef as ComponentDefInternal).directiveDefs = + (MyApp.ngComponentDef as ComponentDef).directiveDefs = [ContentQueryComponent.ngComponentDef, SomeDirective.ngDirectiveDef]; // /NON-NORMATIVE diff --git a/packages/core/test/render3/compiler_canonical/small_app_spec.ts b/packages/core/test/render3/compiler_canonical/small_app_spec.ts index 621203368a..0a98debf2c 100644 --- a/packages/core/test/render3/compiler_canonical/small_app_spec.ts +++ b/packages/core/test/render3/compiler_canonical/small_app_spec.ts @@ -100,7 +100,7 @@ class ToDoAppComponent { } // NON-NORMATIVE -(ToDoAppComponent.ngComponentDef as r3.ComponentDefInternal).directiveDefs = () => +(ToDoAppComponent.ngComponentDef as r3.ComponentDef).directiveDefs = () => [ToDoItemComponent.ngComponentDef, (NgForOf as r3.DirectiveType>).ngDirectiveDef]; // /NON-NORMATIVE diff --git a/packages/core/test/render3/compiler_canonical/template_variables_spec.ts b/packages/core/test/render3/compiler_canonical/template_variables_spec.ts index d32d03344f..b0630711e0 100644 --- a/packages/core/test/render3/compiler_canonical/template_variables_spec.ts +++ b/packages/core/test/render3/compiler_canonical/template_variables_spec.ts @@ -8,7 +8,7 @@ import {Component, Directive, Input, SimpleChanges, TemplateRef, ViewContainerRef, inject} from '../../../src/core'; import * as $r3$ from '../../../src/core_render3_private_export'; -import {ComponentDefInternal} from '../../../src/render3/interfaces/definition'; +import {ComponentDef} from '../../../src/render3/interfaces/definition'; import {renderComponent, toHtml} from '../render_util'; @@ -129,7 +129,7 @@ describe('template variables', () => { } // NON-NORMATIVE - (MyComponent.ngComponentDef as ComponentDefInternal).directiveDefs = + (MyComponent.ngComponentDef as ComponentDef).directiveDefs = [ForOfDirective.ngDirectiveDef]; // /NON-NORMATIVE diff --git a/packages/core/test/render3/component_spec.ts b/packages/core/test/render3/component_spec.ts index 0957268fce..86b131b997 100644 --- a/packages/core/test/render3/component_spec.ts +++ b/packages/core/test/render3/component_spec.ts @@ -11,7 +11,7 @@ import {DoCheck, Input, TemplateRef, ViewContainerRef, ViewEncapsulation, create import {getRenderedText} from '../../src/render3/component'; import {AttributeMarker, ComponentFactory, LifecycleHooksFeature, defineComponent, directiveInject, markDirty, template} from '../../src/render3/index'; import {bind, container, containerRefreshEnd, containerRefreshStart, element, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, nextContext, text, textBinding, tick} from '../../src/render3/instructions'; -import {ComponentDefInternal, DirectiveDefInternal, RenderFlags} from '../../src/render3/interfaces/definition'; +import {ComponentDef, DirectiveDef, RenderFlags} from '../../src/render3/interfaces/definition'; import {createRendererType2} from '../../src/view/index'; import {NgIf} from './common_with_def'; @@ -386,7 +386,7 @@ describe('recursive components', () => { }); } - (TreeComponent.ngComponentDef as ComponentDefInternal).directiveDefs = + (TreeComponent.ngComponentDef as ComponentDef).directiveDefs = () => [TreeComponent.ngComponentDef]; /** @@ -446,7 +446,7 @@ describe('recursive components', () => { } } - (NgIfTree.ngComponentDef as ComponentDefInternal).directiveDefs = + (NgIfTree.ngComponentDef as ComponentDef).directiveDefs = () => [NgIfTree.ngComponentDef, NgIf.ngDirectiveDef]; function _buildTree(currDepth: number): TreeNode { diff --git a/packages/core/test/render3/ivy/jit_spec.ts b/packages/core/test/render3/ivy/jit_spec.ts index 6a8689c888..882a8e1dbd 100644 --- a/packages/core/test/render3/ivy/jit_spec.ts +++ b/packages/core/test/render3/ivy/jit_spec.ts @@ -13,8 +13,8 @@ import {Injectable} from '@angular/core/src/di/injectable'; import {inject, setCurrentInjector} from '@angular/core/src/di/injector'; import {ivyEnabled} from '@angular/core/src/ivy_switch/compiler/index'; import {Component, HostBinding, HostListener, Input, Output, Pipe} from '@angular/core/src/metadata/directives'; -import {NgModule, NgModuleDefInternal} from '@angular/core/src/metadata/ng_module'; -import {ComponentDefInternal, PipeDefInternal} from '@angular/core/src/render3/interfaces/definition'; +import {NgModule, NgModuleDef} from '@angular/core/src/metadata/ng_module'; +import {ComponentDef, PipeDef} from '@angular/core/src/render3/interfaces/definition'; ivyEnabled && describe('render3 jit', () => { @@ -155,7 +155,7 @@ ivyEnabled && describe('render3 jit', () => { class Module { } - const moduleDef: NgModuleDefInternal = (Module as any).ngModuleDef; + const moduleDef: NgModuleDef = (Module as any).ngModuleDef; expect(moduleDef).toBeDefined(); expect(moduleDef.declarations.length).toBe(1); expect(moduleDef.declarations[0]).toBe(Cmp); @@ -193,7 +193,7 @@ ivyEnabled && describe('render3 jit', () => { }) class Cmp { } - const cmpDef: ComponentDefInternal = (Cmp as any).ngComponentDef; + const cmpDef: ComponentDef = (Cmp as any).ngComponentDef; expect(cmpDef.directiveDefs).toBeNull(); @@ -203,7 +203,7 @@ ivyEnabled && describe('render3 jit', () => { class Module { } - const moduleDef: NgModuleDefInternal = (Module as any).ngModuleDef; + const moduleDef: NgModuleDef = (Module as any).ngModuleDef; expect(cmpDef.directiveDefs instanceof Function).toBe(true); expect((cmpDef.directiveDefs as Function)()).toEqual([cmpDef]); }); @@ -225,7 +225,7 @@ ivyEnabled && describe('render3 jit', () => { onChange(event: any): void {} } - const cmpDef = (Cmp as any).ngComponentDef as ComponentDefInternal; + const cmpDef = (Cmp as any).ngComponentDef as ComponentDef; expect(cmpDef.hostBindings).toBeDefined(); expect(cmpDef.hostBindings !.length).toBe(2); @@ -236,7 +236,7 @@ ivyEnabled && describe('render3 jit', () => { class P { } - const pipeDef = (P as any).ngPipeDef as PipeDefInternal

; + const pipeDef = (P as any).ngPipeDef as PipeDef

; expect(pipeDef.name).toBe('test-pipe'); expect(pipeDef.pure).toBe(false, 'pipe should not be pure'); expect(pipeDef.factory() instanceof P) @@ -248,7 +248,7 @@ ivyEnabled && describe('render3 jit', () => { class P { } - const pipeDef = (P as any).ngPipeDef as PipeDefInternal

; + const pipeDef = (P as any).ngPipeDef as PipeDef

; expect(pipeDef.pure).toBe(true, 'pipe should be pure'); }); diff --git a/packages/core/test/render3/jit_environment_spec.ts b/packages/core/test/render3/jit_environment_spec.ts index 04ff0d11e9..5689b7f916 100644 --- a/packages/core/test/render3/jit_environment_spec.ts +++ b/packages/core/test/render3/jit_environment_spec.ts @@ -13,11 +13,11 @@ import {angularCoreEnv} from '../../src/render3/jit/environment'; const INTERFACE_EXCEPTIONS = new Set([ 'ɵBaseDef', - 'ɵComponentDef', - 'ɵDirectiveDef', + 'ɵComponentDefWithMeta', + 'ɵDirectiveDefWithMeta', 'ɵInjectorDef', - 'ɵNgModuleDef', - 'ɵPipeDef', + 'ɵNgModuleDefWithMeta', + 'ɵPipeDefWithMeta', ]); describe('r3 jit environment', () => { diff --git a/packages/core/test/render3/ng_on_changes_feature_spec.ts b/packages/core/test/render3/ng_on_changes_feature_spec.ts index 6ec86072c6..c0034bf37c 100644 --- a/packages/core/test/render3/ng_on_changes_feature_spec.ts +++ b/packages/core/test/render3/ng_on_changes_feature_spec.ts @@ -8,7 +8,7 @@ import {DoCheck, EventEmitter, Input, OnChanges, Output, SimpleChange, SimpleChanges} from '../../src/core'; import {InheritDefinitionFeature} from '../../src/render3/features/inherit_definition_feature'; -import {DirectiveDefInternal, NgOnChangesFeature, defineComponent, defineDirective} from '../../src/render3/index'; +import {DirectiveDef, NgOnChangesFeature, defineComponent, defineDirective} from '../../src/render3/index'; describe('NgOnChangesFeature', () => { it('should patch class', () => { @@ -36,14 +36,14 @@ describe('NgOnChangesFeature', () => { } const myDir = - (MyDirective.ngDirectiveDef as DirectiveDefInternal).factory() as MyDirective; + (MyDirective.ngDirectiveDef as DirectiveDef).factory() as MyDirective; myDir.valA = 'first'; expect(myDir.valA).toEqual('first'); myDir.valB = 'second'; expect(myDir.log).toEqual(['second']); expect(myDir.valB).toEqual('works'); myDir.log.length = 0; - (MyDirective.ngDirectiveDef as DirectiveDefInternal).doCheck !.call(myDir); + (MyDirective.ngDirectiveDef as DirectiveDef).doCheck !.call(myDir); const changeA = new SimpleChange(undefined, 'first', true); const changeB = new SimpleChange(undefined, 'second', true); expect(myDir.log).toEqual(['ngOnChanges', 'valA', changeA, 'valB', changeB, 'ngDoCheck']); @@ -88,8 +88,8 @@ describe('NgOnChangesFeature', () => { }); } - const myDir = (SubDirective.ngDirectiveDef as DirectiveDefInternal) - .factory() as SubDirective; + const myDir = + (SubDirective.ngDirectiveDef as DirectiveDef).factory() as SubDirective; myDir.valA = 'first'; expect(myDir.valA).toEqual('first'); @@ -100,7 +100,7 @@ describe('NgOnChangesFeature', () => { expect(myDir.valC).toEqual('third'); log.length = 0; - (SubDirective.ngDirectiveDef as DirectiveDefInternal).doCheck !.call(myDir); + (SubDirective.ngDirectiveDef as DirectiveDef).doCheck !.call(myDir); const changeA = new SimpleChange(undefined, 'first', true); const changeB = new SimpleChange(undefined, 'second', true); const changeC = new SimpleChange(undefined, 'third', true); @@ -141,12 +141,12 @@ describe('NgOnChangesFeature', () => { }); } - const myDir = (SubDirective.ngDirectiveDef as DirectiveDefInternal) - .factory() as SubDirective; + const myDir = + (SubDirective.ngDirectiveDef as DirectiveDef).factory() as SubDirective; myDir.valA = 'first'; myDir.valB = 'second'; - (SubDirective.ngDirectiveDef as DirectiveDefInternal).doCheck !.call(myDir); + (SubDirective.ngDirectiveDef as DirectiveDef).doCheck !.call(myDir); const changeA = new SimpleChange(undefined, 'first', true); const changeB = new SimpleChange(undefined, 'second', true); expect(log).toEqual([changeA, changeB, 'sub ngDoCheck']); @@ -182,12 +182,12 @@ describe('NgOnChangesFeature', () => { }); } - const myDir = (SubDirective.ngDirectiveDef as DirectiveDefInternal) - .factory() as SubDirective; + const myDir = + (SubDirective.ngDirectiveDef as DirectiveDef).factory() as SubDirective; myDir.valA = 'first'; myDir.valB = 'second'; - (SubDirective.ngDirectiveDef as DirectiveDefInternal).doCheck !.call(myDir); + (SubDirective.ngDirectiveDef as DirectiveDef).doCheck !.call(myDir); const changeA = new SimpleChange(undefined, 'first', true); const changeB = new SimpleChange(undefined, 'second', true); expect(log).toEqual([changeA, changeB, 'super ngDoCheck']); @@ -236,8 +236,8 @@ describe('NgOnChangesFeature', () => { }); } - const myDir = (SubDirective.ngDirectiveDef as DirectiveDefInternal) - .factory() as SubDirective; + const myDir = + (SubDirective.ngDirectiveDef as DirectiveDef).factory() as SubDirective; myDir.valA = 'first'; expect(myDir.valA).toEqual('first'); @@ -249,7 +249,7 @@ describe('NgOnChangesFeature', () => { expect(myDir.valC).toEqual('third'); log.length = 0; - (SubDirective.ngDirectiveDef as DirectiveDefInternal).doCheck !.call(myDir); + (SubDirective.ngDirectiveDef as DirectiveDef).doCheck !.call(myDir); const changeA = new SimpleChange(undefined, 'first', true); const changeB = new SimpleChange(undefined, 'second', true); const changeC = new SimpleChange(undefined, 'third', true); @@ -279,17 +279,17 @@ describe('NgOnChangesFeature', () => { } const myDir = - (MyDirective.ngDirectiveDef as DirectiveDefInternal).factory() as MyDirective; + (MyDirective.ngDirectiveDef as DirectiveDef).factory() as MyDirective; myDir.valA = 'first'; myDir.valB = 'second'; - (MyDirective.ngDirectiveDef as DirectiveDefInternal).doCheck !.call(myDir); + (MyDirective.ngDirectiveDef as DirectiveDef).doCheck !.call(myDir); const changeA1 = new SimpleChange(undefined, 'first', true); const changeB1 = new SimpleChange(undefined, 'second', true); expect(myDir.log).toEqual(['valA', changeA1, 'valB', changeB1]); myDir.log.length = 0; myDir.valA = 'third'; - (MyDirective.ngDirectiveDef as DirectiveDefInternal).doCheck !.call(myDir); + (MyDirective.ngDirectiveDef as DirectiveDef).doCheck !.call(myDir); const changeA2 = new SimpleChange('first', 'third', false); expect(myDir.log).toEqual(['valA', changeA2, 'valB', undefined]); }); @@ -315,10 +315,10 @@ describe('NgOnChangesFeature', () => { } const myDir = - (MyDirective.ngDirectiveDef as DirectiveDefInternal).factory() as MyDirective; + (MyDirective.ngDirectiveDef as DirectiveDef).factory() as MyDirective; myDir.onlySetter = 'someValue'; expect(myDir.onlySetter).toBeUndefined(); - (MyDirective.ngDirectiveDef as DirectiveDefInternal).doCheck !.call(myDir); + (MyDirective.ngDirectiveDef as DirectiveDef).doCheck !.call(myDir); const changeSetter = new SimpleChange(undefined, 'someValue', true); expect(myDir.log).toEqual(['someValue', 'ngOnChanges', 'onlySetter', changeSetter]); }); diff --git a/packages/core/test/render3/render_util.ts b/packages/core/test/render3/render_util.ts index 8136be1b23..c251c69ce7 100644 --- a/packages/core/test/render3/render_util.ts +++ b/packages/core/test/render3/render_util.ts @@ -18,9 +18,9 @@ import {CreateComponentOptions} from '../../src/render3/component'; import {getContext, isComponentInstance} from '../../src/render3/context_discovery'; import {extractDirectiveDef, extractPipeDef} from '../../src/render3/definition'; import {NG_ELEMENT_ID} from '../../src/render3/fields'; -import {ComponentTemplate, ComponentType, DirectiveDefInternal, DirectiveType, PublicFeature, RenderFlags, defineComponent, defineDirective, renderComponent as _renderComponent, tick} from '../../src/render3/index'; +import {ComponentTemplate, ComponentType, DirectiveDef, DirectiveType, PublicFeature, RenderFlags, defineComponent, defineDirective, renderComponent as _renderComponent, tick} from '../../src/render3/index'; import {renderTemplate} from '../../src/render3/instructions'; -import {DirectiveDefList, DirectiveTypesOrFactory, PipeDefInternal, PipeDefList, PipeTypesOrFactory} from '../../src/render3/interfaces/definition'; +import {DirectiveDefList, DirectiveTypesOrFactory, PipeDef, PipeDefList, PipeTypesOrFactory} from '../../src/render3/interfaces/definition'; import {LElementNode} from '../../src/render3/interfaces/node'; import {PlayerHandler} from '../../src/render3/interfaces/player'; import {RElement, RText, Renderer3, RendererFactory3, domRendererFactory3} from '../../src/render3/interfaces/renderer'; @@ -198,13 +198,13 @@ export function renderToHtml( function toDefs( types: DirectiveTypesOrFactory | undefined | null, - mapFn: (type: Type) => DirectiveDefInternal): DirectiveDefList|null; + mapFn: (type: Type) => DirectiveDef): DirectiveDefList|null; function toDefs( types: PipeTypesOrFactory | undefined | null, - mapFn: (type: Type) => PipeDefInternal): PipeDefList|null; + mapFn: (type: Type) => PipeDef): PipeDefList|null; function toDefs( types: PipeTypesOrFactory | DirectiveTypesOrFactory | undefined | null, - mapFn: (type: Type) => PipeDefInternal| DirectiveDefInternal): any { + mapFn: (type: Type) => PipeDef| DirectiveDef): any { if (!types) return null; if (typeof types == 'function') { types = types(); diff --git a/packages/core/test/render3/view_container_ref_spec.ts b/packages/core/test/render3/view_container_ref_spec.ts index 445bee9175..3049ef9a4c 100644 --- a/packages/core/test/render3/view_container_ref_spec.ts +++ b/packages/core/test/render3/view_container_ref_spec.ts @@ -965,7 +965,7 @@ describe('ViewContainerRef', () => { {provide: RendererFactory2, useValue: getRendererFactory2(document)} ] }); - static ngModuleDef: NgModuleDef = { bootstrap: [] } as any; + static ngModuleDef: NgModuleDef = { bootstrap: [] } as any; } const myAppModuleFactory = new NgModuleFactory(MyAppModule); const ngModuleRef = myAppModuleFactory.create(null); diff --git a/packages/core/testing/src/r3_test_bed.ts b/packages/core/testing/src/r3_test_bed.ts index b1247aae6f..9dbabca5f1 100644 --- a/packages/core/testing/src/r3_test_bed.ts +++ b/packages/core/testing/src/r3_test_bed.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Component, Directive, Injector, NgModule, Pipe, PlatformRef, Provider, RendererFactory2, SchemaMetadata, Type, ɵInjectableDef as InjectableDef, ɵNgModuleDefInternal as NgModuleDefInternal, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵRender3ComponentFactory as ComponentFactory, ɵRender3DebugRendererFactory2 as Render3DebugRendererFactory2, ɵRender3NgModuleRef as NgModuleRef, ɵWRAP_RENDERER_FACTORY2 as WRAP_RENDERER_FACTORY2, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵstringify as stringify} from '@angular/core'; +import {Component, Directive, Injector, NgModule, Pipe, PlatformRef, Provider, RendererFactory2, SchemaMetadata, Type, ɵInjectableDef as InjectableDef, ɵNgModuleDef as NgModuleDef, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵRender3ComponentFactory as ComponentFactory, ɵRender3DebugRendererFactory2 as Render3DebugRendererFactory2, ɵRender3NgModuleRef as NgModuleRef, ɵWRAP_RENDERER_FACTORY2 as WRAP_RENDERER_FACTORY2, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵstringify as stringify} from '@angular/core'; import {ComponentFixture} from './component_fixture'; import {MetadataOverride} from './metadata_override'; @@ -557,7 +557,7 @@ function transitiveScopesFor( // Components, Directives, NgModules, and Pipes can all be exported. ngComponentDef?: any; ngDirectiveDef?: any; - ngModuleDef?: NgModuleDefInternal; + ngModuleDef?: NgModuleDef; ngPipeDef?: any; }; @@ -598,6 +598,6 @@ function flatten(values: any[]): T[] { return out; } -function isNgModule(value: Type): value is Type&{ngModuleDef: NgModuleDefInternal} { - return (value as{ngModuleDef?: NgModuleDefInternal}).ngModuleDef !== undefined; +function isNgModule(value: Type): value is Type&{ngModuleDef: NgModuleDef} { + return (value as{ngModuleDef?: NgModuleDef}).ngModuleDef !== undefined; }