angular-cli: Error encountered resolving symbol values statically

Please provide us with the following information:


Mac OSX (El Capitan)


@angular/cli: 1.0.0-beta.30 node: 7.0.0 os: darwin x64 @angular/common: 2.4.6 @angular/compiler: 2.4.6 @angular/core: 2.4.6 @angular/forms: 2.4.6 @angular/http: 2.4.6 @angular/platform-browser: 2.4.6 @angular/platform-browser-dynamic: 2.4.6 @angular/router: 3.4.6 @angular/cli: 1.0.0-beta.30 @angular/compiler-cli: 2.4.6

Repro steps.

Added a simple Opaque Token and NG-BUILD failed as the PROVIDER

import { OpaqueToken } from '@angular/core';

export const SUMMARRY = new OpaqueToken('summary');
const dictionary = { };

// providers
export const SUMMARY_PROVIDER = 
    { provide: SUMMARY, useValue: dictionary },

The log given by the failure.

ERROR in Error encountered resolving symbol values statically. Reference to a local (non-exported) symbol ‘dictionary’. Consider exporting the symbol (position 14:7 in the original .ts file), resolving symbol SUMMARY_PROVIDERS

Any other information

To workaround this:

  1. I put the dictionary inside a single quotes
  2. Ran ng-build and then ng-serve
  3. The code failed as it is now a string
  4. Went back to code and removed the single quotes
  5. Webpack did not complain and the code works fine

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (7 by maintainers)

Most upvoted comments

I have the same issue:

Package A has an InjectionToken T defined in it. Package B depends on Package A. It uses token T in the providers as follows: { provide: TokenT, useValue: SampleValue }

I bundle Package A using WebPack. The error is thrown that TokenT is not statically analyzable, and I must use initialized variables or constants. If I define TokenT in PackageB (not from an external package) then the error is resolved. Is there a way to either disable static analyzing or allow InjectionTokens to be used across multiple packages? Any ideas how to solve that issue?

Export dictionary and the error should go away

I got the same Error encountered resolving symbol values statically.

MyService {
  constructor(@Inject(ConfigToken) config: {[key: string]: string}) {}

// Which was provided as static value in the same module:
{ provide: ConfigToken, useValue: { 'a': 'b' } }

The error disappeared when I removed the type information:

MyService {
  constructor(@Inject(ConfigToken) config: any) {}