angular: AoT compiling error when there is a service defined within some namespace
Hello, I’m submitting a bug report.
Current behavior
When I’m compiling my app with ng build -prod
I got a following error:
ERROR in Illegal state: symbol without members expected, but got {"filePath":"/home/stepo/tmp/service-test/src/app/dummy.service.ts","name":"SomeNamespace","members":["DummyService"]}.
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/stepo/git/service-test/src'
@ ./src/main.ts 4:0-74
@ multi ./src/main.ts
Expected behavior
I expect the application compiles with no problems. If I useng build
or older Angular 2.x and angular-cli there is no problem.
Minimal reproduction of the problem with instructions dummy.service.ts:
import { Injectable } from '@angular/core';
export namespace SomeNamespace {
@Injectable()
export class DummyService {
getData() {
return { 'hello': 'world' };
}
}
}
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { SomeNamespace } from './dummy.service'
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, FormsModule, HttpModule],
providers: [SomeNamespace.DummyService],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts:
import { Component, OnInit } from '@angular/core';
import { SomeNamespace } from './dummy.service';
@Component({
selector: 'app-root',
template: `<pre>{{response}}</pre>`
})
export class AppComponent {
response: string = 'waiting for response...';
constructor(private s: SomeNamespace.DummyService) { }
ngOnInit() {
this.response = JSON.stringify(this.s.getData());
}
}
Environment:
- Angular version: 4.0.0
{
"name": "service-test",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
- Browser: all
- Language: TypeScript 2.2
- Node (for AoT issues):
node --version
= v7.4.0, v7.8.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 20 (5 by maintainers)
Is there a workaround ? Or a solution ?
clients-http.service.ts
clients-http-sender.module.ts
Builds AOT through the CLI and is usable UMD packaged on a npm repository through ng-packagr@^2.0.0