fix(ivy): ngtsc should include generic types on injectable definitions (#27037)
Analogously to directives, the `ngInjectableDef` field in .d.ts files is annotated with the type of service that it represents. If the service contains required generic type arguments, these must be included in the .d.ts file. PR Close #27037
This commit is contained in:
@ -46,6 +46,24 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵInjectableDef<Service>;');
|
||||
});
|
||||
|
||||
it('should compile Injectables with a generic service', () => {
|
||||
env.tsconfig();
|
||||
env.write('test.ts', `
|
||||
import {Injectable} from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class Store<T> {}
|
||||
`);
|
||||
|
||||
env.driveMain();
|
||||
|
||||
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('Store.ngInjectableDef =');
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵInjectableDef<Store<any>>;');
|
||||
});
|
||||
|
||||
it('should compile Components without errors', () => {
|
||||
env.tsconfig();
|
||||
env.write('test.ts', `
|
||||
|
Reference in New Issue
Block a user