Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR in Error encountered resolving symbol values statically. Calling function 'ɵmakeDecorator'

Related to ERROR in Error encountered resolving symbol values statically

Further reference: 1 2 3 4 5

I am currently building a TypeScript library for Angular (using Angular 4). After enabling AOT, I am getting this error.

ERROR in 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 NgModule in /home/.../node_modules/@angular/core/core.d.ts, resolving symbol MyModule in /home/.../dist/contents.module.d.ts, resolving symbol MyModule in /home/.../dist/contents.module.d.ts

Depending on the Angular version I get this other error instead:

ERROR in Error encountered resolving symbol values statically. Calling function 'makeDecorator', function calls are not supported[...]

Enabling AOT on the Angular project prevented this:

ERROR in MyModule is not an NgModule

like image 614
zurfyx Avatar asked Dec 02 '22 11:12

zurfyx


1 Answers

A better solution:

Force your Angular project (or angular-cli) to load your @angular dependencies from your main project, not the library's one.

tsconfig.json (remember that angular-cli main tsconfig files remain in src/tsconfig.app.json and tsconfig.spec.json)

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

Credits to SebastianSchenk and drew-moore.


Previous attempt:

After a few hours testing and digging through GitHub issue responses...

I found out it was as simple as not having a node_modules/ folder inside the client's installation. That is the library I was working on (click here to go up until the commit it was working OK).

Hence, you might have node_modules whilst working in your development setup, but as soon as you integrate your project into another one remove that folder.

In my case, the reason we I was having a node_modules folder inside the client's folder was due to a previous npm link -> npm link my-package. Since I was working with node_modules on my development setup they were on the linked folder as well.


Note that your issue might as well come from somewhere else:

For example: beware of lambdas, use function instead.

and a lot more:

  • const lambda => export function
  • default export => named export *private, protected accessors should be changed to public for any members accessed from template
  • dynamic component template => static template
  • moduleId should be set on components with templateUrl

make sure to check the full description of each of these — credits to Isaac Mann.

like image 59
zurfyx Avatar answered Jun 01 '23 04:06

zurfyx