The following are metadata errors you may encounter, with explanations and suggested corrections.
Expression form not supported
HELPFUL: The compiler encountered an expression it didn't understand while evaluating Angular metadata.
Language features outside of the compiler's restricted expression syntax can produce this error, as seen in the following example:
// ERROR
export class Fooish { … }
…
const prop = typeof Fooish; // typeof is not valid in metadata
…
// bracket notation is not valid in metadata
{ provide: 'token', useValue: { [prop]: 'value' } };
…
You can use typeof and bracket notation in normal application code.
You just can't use those features within expressions that define Angular metadata.
Avoid this error by sticking to the compiler's restricted expression syntax when writing Angular metadata and be wary of new or unusual TypeScript features.
Reference to a local (non-exported) symbol
HELPFUL: Reference to a local (non-exported) symbol 'symbol name'. Consider exporting the symbol.
The compiler encountered a reference to a locally defined symbol that either wasn't exported or wasn't initialized.
Here's a provider example of the problem.
// ERROR
let foo: number; // neither exported nor initialized
@Component({
selector: 'my-component',
template: … ,
providers: [
{ provide: Foo, useValue: foo }
]
})
export