Skip to content

ng build --prod breaks -> support interface types in injectable constuctors #5757

@MadUser

Description

@MadUser

bug report

Versions

@angular/cli: 1.0.0
node: 6.10.1
os: win32 x64
@angular/animations: 4.0.1
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/material: 2.0.0-beta.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0

Repro steps.

it's the same bug as in the following link but now happens only on prod mode:
Issue: angular/angular#12631
Fix: angular/angular#14894

I have a constructor that uses @Inject to get a dependency, and references an interface as type, constructor( @Inject(Document) private document: Document).

What is the current behavior? (You can also link to an open issue here)

When I run ng build --prod, I get this error:

ERROR in Error encountered resolving symbol values statically. Could not resolve type Document (position 26:88 in the original .ts file), resolving symbol OptimizationTable in E:/dev/WorkPlace/web/js/src/myApp-fa/src/app/site/modules/+optimization/table/optimizationTable.component.ts

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'E:\dev\WorkPlace\web\js\src\myApp\src'
@ ./src/main.ts 5:0-74
@ multi ./src/main.ts

when changed to:
constructor( @Inject(Document) private document: any) it works

What is the new behavior?

would expect to be able to reference an interface in a constructor in conjunction with @Inject.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions