Skip to content

Error encountered resolving symbol values statically with type Storage #4837

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

Closed
devforey opened this issue Feb 20, 2017 · 7 comments
Closed

Comments

@devforey
Copy link

devforey commented Feb 20, 2017

Please provide us with the following information:

OS?

Linux (Ubuntu 16)

Versions.

angular-cli: 1.0.0-beta.28.3
node: 6.9.5
os: linux x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/material: 2.0.0-beta.1
@angular/compiler-cli: 2.4.8

Repro steps.

This app was created using CLI. I am specifying the type of a constructor's argument to typescript's Storage interface.

public constructor(storage: Storage) { }

This only occurs when I'm running ng serve --prod --aot. If I remove --aot the problem goes away.

The log given by the failure.

ERROR in Error encountered resolving symbol values statically. Could not resolve type Storage (position 21:39 in the original .ts file), resolving symbol AuthService in /home/devforey/Documents/carmudi/professional-frontend-web/src/app/core/auth/auth.service.ts

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/devforey/Documents/carmudi/professional-frontend-web/src'
 @ ./src/main.ts 5:0-74
 @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

Thanks! We'll be in touch soon.

@ASHFAQPATWARI
Copy link

ASHFAQPATWARI commented Feb 20, 2017

Facing the same issue. For me type is Window,

ERROR in Error encountered resolving symbol values statically. Could not resolve type Window

@deebloo
Copy link
Contributor

deebloo commented Feb 20, 2017

@devforey can you post your code for "Storage"?

@devforey
Copy link
Author

devforey commented Feb 20, 2017

@deebloo It's from typescript's lib.
/node_modules/typescript/lib/lib.dom.d.ts

the snippet:

interface Storage {
    readonly length: number;
    clear(): void;
    getItem(key: string): string | null;
    key(index: number): string | null;
    removeItem(key: string): void;
    setItem(key: string, data: string): void;
    [key: string]: any;
    [index: number]: string;
}

declare var Storage: {
    prototype: Storage;
    new(): Storage;
}

@deebloo
Copy link
Contributor

deebloo commented Feb 20, 2017

@devforey are you providing it in anyway to angular's dependency injector? Anything that is going to be injected needs to be provided.

@ASHFAQPATWARI this applies to Window as well

@NgModule({
  providers: [
    { provide: 'storage', useValue: Storage }
  ]
})
export class AppModule { }

@Component({
...
})
export class AppComponent {
  constructor(@Inject('storage') private storage) {}
}

@filipesilva
Copy link
Contributor

@deebloo's explanation is pretty good. This isn't a CLI issue per se though, a better place to ask would be stack overflow.

@KostyaTretyak
Copy link

KostyaTretyak commented Apr 25, 2017

@devforey, author (devforey) say that the error occurs only with --aot in ng build --prod --aot.
So, dependencies resolved.

I have similar error, but error occurs only with --prod in ng buid --prod.

UPD: I resolved this problem by remove all no needed classes from module providers

@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants