0

I am using some old module: angular-2-local-storage. The way it's being instantiated is the following:

const LOCAL_STORAGE_SERVICE_CONFIG_TOKEN: string = 'LOCAL_STORAGE_SERVICE_CONFIG';
export const LOCAL_STORAGE_SERVICE_CONFIG = new OpaqueToken(LOCAL_STORAGE_SERVICE_CONFIG_TOKEN);

... and further in my code:

@NgModule({
  .....
  providers: [
      LocalStorageService,
    {
      provide: LOCAL_STORAGE_SERVICE_CONFIG,
      useValue: { prefix: 'miswap' }
    },
    {

But when building my project, I receive this:

Error: Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 2:22 in the original .ts file), resolving symbol LOCAL_STORAGE_SERVICE_CONFIG in ....

This is where I am totally lost.

The issue looks like OpaqueToken deprecation as mentioned here. However, my project is Angular 2, not 4.

So, do I miss something? Is this because of some angular cli version wrong? Don't even know where to find solution!

This is part of my package.json if that might help:

  "devDependencies": {
    "@angular/compiler-cli": "^2.0.0",
    "@angular/platform-server": "2.0.0",
    "@angular/tsc-wrapped": "0.3.0",
    "@types/async": "2.0.31",
    "@types/core-js": "0.9.32",
NTP
  • 4,338
  • 3
  • 16
  • 24
Agat
  • 4,577
  • 2
  • 34
  • 62

1 Answers1

0

Just an idea: What is the value of LOCAL_STORAGE_SERVICE_CONFIG before providing it? Try console.log(LOCAL_STORAGE_SERVICE_CONFIG) right before declaration of the @NgModule. If its undefined, you are either not importing it properly, so the value is missing, or there is a problem with new OpaqueToken() - is OpaqueToken undefined?

gazorpazorp
  • 468
  • 3
  • 13
  • I am not sure where you would want me to run `console.log` as this is not my app runtime error. The app itself functioning well when launched (in dev, and old version of prod). However, I receive it when forcing gulp build.dev.exp. And the error itself rather referring to semantics, I guess. – Agat Dec 30 '17 at 19:10