angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Getting Error encountered resolving symbol values statically. Calling function 'makeDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable

Open xtianus79 opened this issue 9 years ago • 61 comments

OS?

MacOS Sierre

Versions.

angular-cli: 1.0.0-beta.19-3 node: 6.2.2 os: darwin x64

Repro steps.

Getting this error with using Angular CLI

Error encountered resolving symbol values statically. Calling function 'makeDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in /Users/mbp06/Repos/multiple-date-picker-a2/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in /Users/mbp06/Repos/multiple-date-picker-a2/node_modules/@angular/core/src/di/opaque_token.d.ts, resolving symbol OpaqueToken in /Users/mbp06/Repos/multiple-date-picker-a2/node_modules/@angular/core/src/di/opaque_token.d.ts

xtianus79 avatar Feb 13 '17 04:02 xtianus79

@Simon-Briggs's solution worked for me also using Angular 4.

  "dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
  "peerDependencies": {
    "@angular/common": ">=4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": ">=4.0.0",
    etc

yoojene avatar Jun 01 '17 12:06 yoojene

I had the same issue with error "ERROR in Error encountered resolving symbol values statically. Calling function ɵmakeDecorator". In my case it was happening when I linked angular-library-seed (that was developed locally) to Angular CLI project via yarn link and then ran ng build --prod to test AOT build. For some reason having node_modules folder in my linked library caused that error.

The following workaround https://github.com/angular/angular-cli/issues/3854#issuecomment-274344771 has saved my day. Specifying paths to @angular inside AngularCLI's tsconfig.json prevented the error from happening.

"paths": { "@angular/*": ["../node_modules/@angular/*"] }

More details here https://github.com/angular/angular-cli/issues/3854#issuecomment-274344771 and here https://github.com/angular/angular-cli/issues/3854#issuecomment-299109237.

trekhleb avatar Jun 03 '17 10:06 trekhleb

Troubleshooting for several days and here is the solution. you save my career. Thanks.

ada024 avatar Jun 05 '17 11:06 ada024

@trekhleb you saved my day too, thanks!

uberroot4 avatar Jun 06 '17 06:06 uberroot4

@trekhleb answer is the correct answer... everybody stop looking for it.

sollenne avatar Jun 07 '17 18:06 sollenne

In my case what worked out was extract all the provider configuration object to the provider file:

// custom-http.service.ts

@Injectable()
export class CustomHttpService extends Http { ... }

export function customHttpFactory (backend: XHRBackend, defaultOptions: RequestOptions) {
    return new CustomHttpService(backend, defaultOptions);
};

export let customHttpProvider = {
  provide: CustomHttpService,
  useFactory: customHttpFactory,
  deps: [ XHRBackend, RequestOptions ]
};

// app.module.ts

import { customHttpProvider } from './shared/services/custom-http/custom-http.service';
@NgModule({
providers: [
    customHttpProvider
 ],
...
}

Don't use a arrow function when exporting the Factory (customHttpFactory in this case), it will fail.

aleixsuau avatar Jun 08 '17 09:06 aleixsuau

facing below issue when importing function from module as 'RiaCommonsModule.forRoot()'

ERROR in Error encountered resolving symbol values statically. Calling function 'RiaCommonsModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol getRiaCommonsModule in D:/SureCall/Angular-CLI/AnC-Client/src/app/app.module.lib.ts, resolving symbol AppModuleLib in D:/SureCall/Angular-CLI/AnC-Client/src/app/app.module.lib.ts, resolving symbol AppModuleLib in D:/SureCall/Angular-CLI/AnC-Client/src/app/app.module.lib.ts

amolpshinde07 avatar Jun 19 '17 12:06 amolpshinde07

@trekhleb 's solution did not work for me, unfortunately. I have the exact same error as him, and I don't have any yarn-linked projects (although I have one external project being referenced in a lot of components, but I reference it directly, not via yarn link).

I have specified paths in the tsconfig.json file but I still receive the same error:

Error: Error encountered resolving symbol values statically. Calling function 'makeParamDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in /Users/muriloromera/Documents/Git Repos/reserva-de-espacos/Shared/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in /Users/muriloromera/Documents/Git Repos/reserva-de-espacos/Shared/node_modules/@angular/core/src/di/opaque_token.d.ts, resolving symbol OpaqueToken in /Users/muriloromera/Documents/Git Repos/reserva-de-espacos/Shared/node_modules/@angular/core/src/di/opaque_token.d.ts

Mumumurilo avatar Jul 12 '17 18:07 Mumumurilo

@trekhleb for me it is working too ... thank you.

sciborrudnicki avatar Jul 13 '17 16:07 sciborrudnicki

Adding "paths": { "@angular/*": ["../node_modules/@angular/*"] }, in tsconfig.json file worked for me too. Thanks @trekhleb.

lukeclifton avatar Jul 18 '17 09:07 lukeclifton

I followed @Simon-Briggs April 4 suggestion, and in addition removed the dependency's node_modules folder. Working fine now.

trickmeyer avatar Jul 19 '17 18:07 trickmeyer

@trekhleb 's solution didnt work for me too. I added path in tsconfig.json file but still receive the same error

Fiv38 avatar Jul 24 '17 09:07 Fiv38

I've got ng2-translate modul TranslateStaticLoader problem like @webernir. his solution can't fixed my problem, but after I add "export" keyword to his httpFactory function error fixed, like this: ... export function httpFactory(http: Http) { return new TranslateStaticLoader(http, '/assets/i18n', '.json'); } ... hope this helps someone

ilia5050 avatar Jul 27 '17 12:07 ilia5050

Thank you for your reply, hey the problem was solved,

I add you on Github k?

2017-08-04 20:19 GMT+07:00 Sukaina Rizvi [email protected]:

Try: npm install --save @angular/cdk

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/4647#issuecomment-320246678, or mute the thread https://github.com/notifications/unsubscribe-auth/AbyrUB_38zBLXyg5rI0U8uOroZJGb6W3ks5sUxpPgaJpZM4L-xjH .

Fiv38 avatar Aug 09 '17 07:08 Fiv38

I made this mistake when I created a new project, but tried all the solutions failed, what should I do?

deepthan avatar Sep 28 '17 09:09 deepthan

Plus one

lauradelarie avatar Sep 29 '17 08:09 lauradelarie

@trekhleb for me it is working too :D

leticiafatimaa avatar Oct 04 '17 16:10 leticiafatimaa

Just FYI there's now official troubleshooting guide for this error https://angular.io/guide/metadata#function-calls-are-not-supported.

None of the things listed there helped me.

It turned out the problem was that the library I'm developing didn't specify typings in its package.json.

martinsik avatar Oct 08 '17 20:10 martinsik

@trekhleb your solution does not work for me. I am getting following error message when trying to import angular-seed-library into a ionic project.

1: I have tried "paths": { "@angular/": ["../node_modules/@angular/"] } in both tsconfig of angular-seed-library and also in ionic project no solution still the same error. 2: This error appears if I do yarn link and then run ionic-app-scripts build --prod 3: its over a month now since I am struck with this error. I do hope you understand my position here now :( I will really appreciate, if any one can help on this.

LoginComponent is a component that I have made in angular-library-seed at the moment its very simple and basic component.

$ yarn build:aot
yarn build:aot v0.27.5
$ ionic-app-scripts build --prod
[23:38:18]  ionic-app-scripts 2.1.4
[23:38:18]  build prod started ...
[23:38:18]  clean started ...
[23:38:18]  clean finished in 1 ms
[23:38:18]  copy started ...
[23:38:18]  ngc started ...
[23:38:21]  ionic-app-script task: "build"
[23:38:21]  Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider  replacing the function or lambda with a reference to an exported function 
(position 756:18 in the original .ts file),

resolving symbol Component in C:/Monsenso-Source/administration/node_modules/@monsenso/ 
components/node_modules/@angular/core/core.d.ts,

resolving symbol LoginComponent in C:/Monsenso-Source/administration/node_modules/@monsenso/
components/lib/components/login/login.component.d.ts,

resolving symbol LoginComponent in C:/Monsenso-Source/administration/node_modules/@monsenso/ 
components/lib/components/login/login.component.d.ts

Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider 
replacing the function or lambda with a reference to an exported function (position 756:18 in the original
 .ts file), resolving symbol Component in 
C:/Monsenso-Source/administration/node_modules/@monsenso/components/node_modules/ 
@angular/core/core.d.ts,

resolving symbol LoginComponent in C:/Monsenso-Source/administration/node_modules/@monsenso/
 components/lib/components/login/login.component.d.ts, 
resolving symbol LoginComponent in C:/Monsenso-Source/administration/node_modules/@monsenso/ 
components/lib/components/login/login.component.d.ts

    at positionalError (C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\ 
compiler.umd.js:25266:35)

    at simplifyInContext (C:\Monsenso-Source\administration\node_modules\@angular\compiler\ 
bundles\compiler.umd.js:25109:27)

    at StaticReflector.simplify (C:\Monsenso-Source\administration\node_modules\@angular\compiler\ 
bundles\ compiler.umd.js:25123:13)

    at StaticReflector.annotations (C:\Monsenso-ource\administration\node_modules\@angular\compiler\ 
bundles\compiler.umd.js:24553:41)

    at NgModuleResolver.resolve (C:\Monsenso-Source\administration\node_modules\@angular\ 
compiler\ bundles\compiler.umd.js:14891:70)
    at CompileMetadataResolver.getNgModuleMetadata (C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\compiler.umd.js:15546:60)
    at addNgModule (C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\compiler.umd.js:24403:58)
    at C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\compiler.umd.js:24414:14
    at Array.forEach (native)
    at _createNgModules (C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\compiler.umd.js:24413:26)
error Command failed with exit code 1.

qasimraza1979 avatar Oct 10 '17 21:10 qasimraza1979

wow, I wonder if React developers are dealing with issues like this?

jbeckton avatar Oct 20 '17 21:10 jbeckton