I have used a generic provider in my code, which is injected in my components:
@Injectable()
export class BaseService<T> {
getAll(): Observable<T[]> { }
}
It works well when I run ionic liveserver
but if I run ionic build android
the ngc compiler throws the error:
ngc: Error: Error at C:/dev/ecdt-mobile/.tmp/app/app.module.ngfactory.ts:177:20:
Generic type 'BaseService<T>' requires 1 type argument(s).
I’ve checked the app.module.ngfactory.ts file and the error is here:
__BaseService_76:import46.BaseService;
constructor(parent:import47.Injector) {
import46.BaseService is underline in red in my IDE.
What is wrong here ?
I guess the generated code should be something like:
__BaseService_76:import46.BaseService<any>;
Is this a angular issue or ionic issue ?
[EDIT]
I have created a repro with angular only and the compilation does not give any error. What is strange though is that the generated code is the same, with the same code being underlined in my IDE.
Is Ionic using a different version of ngc, which is preventing the code from compiling ?
This is the command line I’ve used for my angular2 repro (without ionic):
"node_modules/.bin/ngc" -p tsconfig-aot.json
and my tsconfig-aot.json file is:
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"types": []
},
"files": [
"app/app.module.ts",
"app/main.ts",
"./typings/index.d.ts"
],
"angularCompilerOptions": {
"genDir": "aot",
"skipMetadataEmit" : true
}
}