Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MadUser opened this issue Mar 30, 2017 · 4 comments
Closed

Comments

@MadUser
Copy link

MadUser commented Mar 30, 2017

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.

@deebloo
Copy link
Contributor

deebloo commented Mar 30, 2017

So from what I understand. TS Interfaces can't be used as provider Tokens because they are a build time construct only and don't exist at runtime.

@DzmitryShylovich
Copy link

it's an angular bug angular/angular#15640

@filipesilva
Copy link
Contributor

Closed as answered by @deebloo and @DzmitryShylovich, thanks!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants