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

in 1.0.0-beta.24 getting ERROR in Error encountered resolving symbol values statically

Open born2net opened this issue 9 years ago • 44 comments

OS?

Windows 10 64

Versions.

latest ng 2.4.1 and cli 1.0.0-beta.24

Repro steps.

Angular 2 Kitchen sink: http://ng2.javascriptninja.io and source@ https://github.com/born2net/Angular-kitchen-sink

ERROR in Error encountered resolving symbol values statically. Calling function 'MsLibModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/msweb/Angular-kitchen-sink/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/Angular-kitchen-sink/src/app/app.module.ts
webpack: bundle is now VALID.

I am loading a module with forRoot as in:

    imports: [
      ...
        MsLibModule.forRoot(),
      ...
    ],

which doens't do much,

export class MsLibModule {
    static forRoot(): ModuleWithProviders {
        return {
            ngModule: MsLibModule,
            providers: []
        };
    }
}

as you can see no lambada needed... and still getting the error of:


ERROR in Error encountered resolving symbol values statically. Calling function 'MsLibModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/msweb/Angular-kitchen-sink/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/Angular-kitchen-sink/src/app/app.module.ts

regards

Sean

born2net avatar Dec 22 '16 15:12 born2net

Have the same problem.

alexeyvasilyev avatar Jan 02 '17 12:01 alexeyvasilyev

Reverting to 1.0.0-beta.19-3 like @alvachien mentioned fixes the issue for me. I also experimented with working backwards through versions and the first version that did not break ng build for me is 1.0.0-beta.21.

zackthoutt avatar Jan 09 '17 18:01 zackthoutt

I'm putting this back out there: "just to add my error into the mix:

ERROR in Error encountered resolving symbol values statically. Could not resolve events relative to /Users/.../node_modules/@types/mongodb/index.d.ts., resolving symbol Db in Users/.../node_modules/@types/mongodb/index.d.ts

Why is it going into mongodb when nothing in my client side code refs that module?"

Devs, any help here?

stusquared avatar Jan 21 '17 21:01 stusquared

@photostu without any project or code to look at there's nothing we can do.

hansl avatar Jan 21 '17 21:01 hansl

Actually I have an idea, try to add "files": ["main.ts"] to your tsconfig.json, tell us if that works.

hansl avatar Jan 21 '17 21:01 hansl

@hansl you can see mine example from above. Just extend the EventEmitter.

ivaylopivanov avatar Jan 21 '17 21:01 ivaylopivanov

I will work on a sample to reproduce

stusquared avatar Jan 21 '17 21:01 stusquared

I think I'm sorted now... I had @types/mongodb in my package.json dependencies. Moving that to devDeps seems to have solved it!

stusquared avatar Jan 21 '17 21:01 stusquared

in my package.json there is no @types/mongodb. what should i do

paruvellyvishwanath avatar Jan 23 '17 07:01 paruvellyvishwanath

well, my backend project needs that @types/mongodb package in dependencies, so I may have to consider splitting out the project :(

stusquared avatar Jan 23 '17 14:01 stusquared

Ha, I just added a build task to rename the offending mongo index.d.ts during the client build step then revert it for server build!

stusquared avatar Jan 23 '17 14:01 stusquared

@paruvellyvishwanath what is your error? You may have another offender package

stusquared avatar Jan 23 '17 14:01 stusquared

when i run npm run build:prod i am getting below error

Error encountered resolving symbol values statically. Could not reso
lve events relative to C:/Users/evontex/Desktop/01 Seed_1/node_modules/@typ
es/mongodb/index.d.ts., resolving symbol Db in C:/Users/evontex/Desktop/01
Seed_1/node_modules/@types/mongodb/index.d.ts

paruvellyvishwanath avatar Jan 24 '17 04:01 paruvellyvishwanath

@photostu can you post your hack?

dustintheweb avatar Feb 03 '17 22:02 dustintheweb

It's really simple, just add 2 build steps to rename the offending file before the client build, then fix it back before your server build. Total hack job.

stusquared avatar Feb 03 '17 23:02 stusquared

came back to confirm. hackasarus rex will have to do until the actual bug gets fixed

dustintheweb avatar Feb 04 '17 16:02 dustintheweb

@photostu Rename to what? If i rename file, i get 'cannot find type definition file for mongodb'.

vdjurdjevic avatar Feb 17 '17 18:02 vdjurdjevic

@vladimirdjurdjevic you have to perform 2 renames in this process. First rename it with a diff extension so the client build doesn't recognize it as a .ts Then, after your client build is finished and you need to perform your server build, you rename it back to its original filename. Hope this makes sense.

stusquared avatar Feb 17 '17 19:02 stusquared

@angular/cli 1.0.0-rc.0 still has same problem. 3 months passed and still we can't use newest AOT to compile our projects that use forRoot static method to provide providers for root module. :(

dmytro-y-dev avatar Feb 27 '17 07:02 dmytro-y-dev

any progress about this issue, we have the same problem.

naiteluo avatar Apr 10 '17 15:04 naiteluo