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.

ERROR in Error: Error encountered resolving symbol values statically. Calling function 'TestModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function

See original GitHub issue

test.module.ts

import { NgModule, ModuleWithProviders } from '@angular/core';
import { TestService } from './test.service';

@NgModule({
	imports: [],
	declarations: [],
	exports: [],
	entryComponents: []
})
export class TestModule {
	static forRoot (): ModuleWithProviders {
		return {
			ngModule: TestModule,
                        providers: [TestService]
		};
	}
}

test.service.ts

import { Injectable } from '@angular/core';

@Injectable()
export class TestService {

    constructor () {
    }

    dialog () {
        return {
            action: 'test'
        };
    }

}

tsconfig.json

{
	"compilerOptions": {
		"noImplicitAny": true,
		"module": "commonjs",
		"target": "ES5",
		"emitDecoratorMetadata": true,
		"experimentalDecorators": true,
		"sourceMap": true,
		"declaration": true,
		"moduleResolution": "node",
		"noUnusedLocals": true,
		"removeComments": false,
		"skipLibCheck": true,
		"outDir": "fe-test/",
		"typeRoots": [
			"../../../node_modules/@types"
		],
        "lib": ["es2015"]
	},
	"files": [ "index.ts" ],
	"exclude": [
		"../../../node_modules"
	]
}

Usage:

cd test && tsc
import { TestModule } from './test/fe-test';

import { AppComponent } from './app.component';
import { appRoutes } from './app.routes';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule.withServerTransition({ appId: 'ang5-seo' }),
        BrowserAnimationsModule,
        FormsModule,
        ReactiveFormsModule,
        RouterModule.forRoot(appRoutes),
        
        TestModule.forRoot()
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule {}

Development environment:

"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/router": "^5.0.0",
"@nguniversal/express-engine": "^5.0.0-beta.5",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",

run

ng serve --prod

Throws Error:

ERROR in Error: Error encountered resolving symbol values statically. Calling function 'TestModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in /Users/wangchengjun/www/yooli/mock/angular5-seo-demo/src/app/app.module.ts, resolving symbol AppModule in /Users/wangchengjun/www/yooli/mock/angular5-seo-demo/src/app/app.module.ts

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Toxicablecommented, Nov 10, 2017

Referencing your src directly rather than the compiled output makes it work meaning you likely have an issue with your bundling config. I don’t see the issue with Angular here

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

ERROR in Error encountered resolving symbol values ...
Calling function 'PerfectScrollbarModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function ...
Read more >
ERROR in Error encountered resolving symbol values ...
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda ...
Read more >
Error encountered resolving symbol values statically - O'Reilly
Calling function 'ModalDialogParams', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, ...
Read more >
angular-ui/ui-router - Gitter
client?93b6:101 Error encountered resolving symbol values statically. Calling function 'UIRouterModule', function calls are not supported. Consider ...
Read more >
The Racket Guide - Northwestern University PLT
This guide is intended for programmers who are new to Racket or new to some part of. Racket. It assumes programming experience, so...
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