Calling function 'InjectionToken', function calls are not supported.
See original GitHub issueI’m submitting a … (check one with “x”)
[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
when I do ng build
I get: Calling function ‘InjectionToken’, function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol UserConfigToken in …
I have created token and I am trying to use it as:
export const UserConfigToken = new InjectionToken<string>('User.Config');
export class CoreModule {
static forRoot(config: {[key: string]: any} = {}): ModuleWithProviders
{
return {
ngModule: CoreModule,
providers: [
{provide: UserConfigToken, useValue: config},
}
Expected behavior
It will compile without these errors
I replaced OpaqueToken with InjectionToken and I think I am using it exactly the same one as in latest angular’s 4.1.0 code e.g. when I look at
export const APP_BASE_HREF = new InjectionToken<string>('appBaseHref');
that I am using as well but I dont see any errors for this one.
I guess this usecase shoudl work…
What is the motivation / use case for changing the behavior? OpaqueToken was deprecated
Please tell us about your environment: I am running on latest Angular 4.1.0 as well as ng 1.0.3
Thanks for any input,
Frank
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
I found this issue on angular -cli https://github.com/angular/angular-cli/issues/3854 whcih resolved my case.
adding path to my tsconfig
But stil not sure what is the real root case. It seems webpack is not able to find and map correct paths?
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.