fix(compiler): recognize @NgModule with a redundant @Injectable (#20320)
The compiler now, again, recognizes `@NgModule()` decorators on classes with a redundant `@Injectable()` decorator. Fixes: #19544 PR Close #20320
This commit is contained in:

committed by
Jason Aden

parent
cf618c564c
commit
c33a57666b
@ -1392,6 +1392,42 @@ describe('ngc transformer command-line', () => {
|
||||
});
|
||||
|
||||
describe('regressions', () => {
|
||||
//#19544
|
||||
it('should recognize @NgModule() directive with a redundant @Injectable()', () => {
|
||||
write('src/tsconfig.json', `{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../dist",
|
||||
"rootDir": ".",
|
||||
"rootDirs": [
|
||||
".",
|
||||
"../dist"
|
||||
]
|
||||
},
|
||||
"files": ["test-module.ts"]
|
||||
}`);
|
||||
write('src/test.component.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: '<p>hello</p>',
|
||||
})
|
||||
export class TestComponent {}
|
||||
`);
|
||||
write('src/test-module.ts', `
|
||||
import {Injectable, NgModule} from '@angular/core';
|
||||
import {TestComponent} from './test.component';
|
||||
|
||||
@NgModule({declarations: [TestComponent]})
|
||||
@Injectable()
|
||||
export class TestModule {}
|
||||
`);
|
||||
const messages: string[] = [];
|
||||
const exitCode =
|
||||
main(['-p', path.join(basePath, 'src/tsconfig.json')], message => messages.push(message));
|
||||
expect(exitCode).toBe(0, 'Compile failed unexpectedly.\n ' + messages.join('\n '));
|
||||
});
|
||||
|
||||
// #19765
|
||||
it('should not report an error when the resolved .css file is in outside rootDir', () => {
|
||||
write('src/tsconfig.json', `{
|
||||
|
Reference in New Issue
Block a user