Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2: ERROR in Error encountered resolving symbol values statically

I am using angular/cli 1.3.2 and Angular 4.4.0. When I use an npm module [email protected],during compilation I met

ERROR in 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 194:50 in the original .ts file), resolving symbol NgModule in path-to-project/node_modules/angular-split/node_modules/@angular/core/core.d.ts, resolving symbol AngularSplitModule in path-to-project/node_modules/angular-split/dist/angularSplit.module.d.ts, resolving symbol AngularSplitModule in path-to-project/node_modules/angular-split/dist/angularSplit.module.d.ts

Here in file angularSplit.module.d.ts there is only one line of code:

export declare class AngularSplitModule {}

However, this error can be "resolved" by saving any file and trigger the recompile (weird).

Then, when I open localhost:4200 in the browser I will see another error:

compiler.es5.js:1694 Uncaught Error: Unexpected value 'AngularSplitModule' imported by the module 'AppModule'. Please add a @NgModule annotation.

From github and stackoverflow I found some similar problems but no one could tell the reason.

This happened after I updated node/angular/angular-cli, but after I roll back it still didn't work.

Does anyone know why this happened?

like image 669
Zanecat Avatar asked Sep 04 '17 10:09

Zanecat


2 Answers

Alright, after hours of reading I found one useful solution here https://github.com/angular/angular-cli/issues/3854#issuecomment-274344771

to be specific, add paths: { "@angular/*": ["../node_modules/@angular/*"] } to tsconfig.json file, "compilerOptions" option

It solves my problem but still wanna know why.

like image 138
Zanecat Avatar answered Nov 11 '22 09:11

Zanecat


I have also encountered the below error:

ERROR in solving symbol values statically. Expression form not supported (position 30:19 in the original .ts file), resolving symbol AppModule in /.../src/app/app.module.ts

In app.module.ts, the code was not formatted properly:

Earlier:

@NgModule({
    declarations: [
        AppComponent,
        HomeComponent,,
    ]

Corrected it to:

@NgModule({
declarations: [    
    AppComponent,
    HomeComponent
  ]

And it worked. Might be useful for anyone. Thanks

like image 22
Anant Avatar answered Nov 11 '22 11:11

Anant