question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling function 'InjectionToken', function calls are not supported.

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

15reactions
fkolarcommented, May 12, 2017

I found this issue on angular -cli https://github.com/angular/angular-cli/issues/3854 whcih resolved my case.

adding path to my tsconfig

 "@angular/*": ["../node_modules/@angular/*"]

But stil not sure what is the real root case. It seems webpack is not able to find and map correct paths?

0reactions
angular-automatic-lock-bot[bot]commented, Sep 12, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function calls are not supported in decorators but ...
trying to setup ngx-formly-material-file, but I got an error: Function calls are not supported in decorators but 'FileTypeModule' was called.
Read more >
Solving AOT Error in NgRx: Function calls are not supported in ...
Solution 2: Use InjectionToken. As documented in NgRx, StoreModule.forRoot can also takes in a InjectionToken which refers to provided root reducer map. This...
Read more >
AOT metadata errors - Angular
Function calls are not supported link. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported...
Read more >
Error in prod build :Function calls are not supported in ...
Hello, I'm getting the following error "ng build --prod" ERROR in Error during template compile of 'MainModule' Function calls are not ...
Read more >
error during template compile of servermodule, error during template ...
GitHub is home to over 50 million developers working together to host and review code, ... function calls are not supported in decorators...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found