diff --git a/packages/compiler/src/injectable_compiler_2.ts b/packages/compiler/src/injectable_compiler_2.ts index 083d2217f4..abe1d9c76c 100644 --- a/packages/compiler/src/injectable_compiler_2.ts +++ b/packages/compiler/src/injectable_compiler_2.ts @@ -52,7 +52,6 @@ export function compileInjectable(meta: R3InjectableMetadata): InjectableDef { fnOrClass, useNew, injectFn: Identifiers.inject, - useOptionalParam: true, deps: meta.deps, }); } else if (meta.useClass !== undefined) { @@ -94,7 +93,6 @@ export function compileInjectable(meta: R3InjectableMetadata): InjectableDef { fnOrClass: meta.type, useNew: true, injectFn: Identifiers.inject, - useOptionalParam: true, deps: meta.deps, }); } diff --git a/packages/compiler/src/render3/r3_factory.ts b/packages/compiler/src/render3/r3_factory.ts index 78d7e3c75c..178434026d 100644 --- a/packages/compiler/src/render3/r3_factory.ts +++ b/packages/compiler/src/render3/r3_factory.ts @@ -55,19 +55,6 @@ export interface R3FactoryMetadata { */ injectFn: o.ExternalReference; - /** - * Whether the `injectFn` given above accepts a 2nd parameter indicating the default value to - * be used to resolve missing @Optional dependencies. - * - * If the optional parameter is used, injectFn for an optional dependency will be invoked as: - * `injectFn(token, null, flags)`. - * - * If it's not used, injectFn for an optional dependency will be invoked as: - * `injectFn(token, flags)`. The Optional flag will indicate that injectFn should select a default - * value if it cannot satisfy the injection request for the token. - */ - useOptionalParam: boolean; - /** * If present, the return of the factory function will be an array with the injected value in the * 0th position and the extra results included in subsequent positions. @@ -162,8 +149,7 @@ export interface R3DependencyMetadata { */ export function compileFactoryFunction(meta: R3FactoryMetadata): o.Expression { // Each dependency becomes an invocation of an inject*() function. - const args = - meta.deps.map(dep => compileInjectDependency(dep, meta.injectFn, meta.useOptionalParam)); + const args = meta.deps.map(dep => compileInjectDependency(dep, meta.injectFn)); // The overall result depends on whether this is construction or function invocation. const expr = meta.useNew ? new o.InstantiateExpr(meta.fnOrClass, args) : @@ -178,8 +164,7 @@ export function compileFactoryFunction(meta: R3FactoryMetadata): o.Expression { } function compileInjectDependency( - dep: R3DependencyMetadata, injectFn: o.ExternalReference, - useOptionalParam: boolean): o.Expression { + dep: R3DependencyMetadata, injectFn: o.ExternalReference): o.Expression { // Interpret the dependency according to its resolved type. switch (dep.resolved) { case R3ResolvedDependencyType.Token: @@ -202,18 +187,7 @@ function compileInjectDependency( // parameters describing how to inject the dependency must be passed to the inject function // that's being used. if (flags !== InjectFlags.Default || dep.optional) { - // Either the dependency is optional, or non-default flags are in use. Either of these cases - // necessitates adding an argument for the default value if such an argument is required - // by the inject function (useOptionalParam === true). - if (useOptionalParam) { - // The inject function requires a default value parameter. - injectArgs.push(dep.optional ? o.NULL_EXPR : o.literal(undefined)); - } - // The last parameter is always the InjectFlags, which only need to be specified if they're - // non-default. - if (flags !== InjectFlags.Default) { - injectArgs.push(o.literal(flags)); - } + injectArgs.push(o.literal(flags)); } return o.importExpr(injectFn).callFn(injectArgs); } diff --git a/packages/compiler/src/render3/r3_pipe_compiler.ts b/packages/compiler/src/render3/r3_pipe_compiler.ts index 98c75db184..a7456b4e7a 100644 --- a/packages/compiler/src/render3/r3_pipe_compiler.ts +++ b/packages/compiler/src/render3/r3_pipe_compiler.ts @@ -37,7 +37,6 @@ export function compilePipe( fnOrClass: outputCtx.importExpr(pipe.type.reference), deps, useNew: true, injectFn: R3.directiveInject, - useOptionalParam: false, }); definitionMapValues.push({key: 'factory', value: templateFactory, quoted: false}); diff --git a/packages/compiler/src/render3/view/compiler.ts b/packages/compiler/src/render3/view/compiler.ts index b6b8f76ae9..63a2462408 100644 --- a/packages/compiler/src/render3/view/compiler.ts +++ b/packages/compiler/src/render3/view/compiler.ts @@ -49,7 +49,6 @@ function baseDirectiveFields( deps: meta.deps, useNew: true, injectFn: R3.directiveInject, - useOptionalParam: false, extraResults: queryDefinitions, }));