fix(compiler-cli): do not force type checking on .js files

The compiler host would force any file that is in node_modules
into the list of files that needed to be type checked which
captures .js files if `allowJs` is set to `true`. This should
have only forced .d.ts files into the project to enable
generation of factories.

Fixes: #19757
This commit is contained in:
Chuck Jazdzewski
2017-12-15 14:51:42 -08:00
committed by Alex Rickabaugh
parent 30208759cd
commit 5f23a1223f
2 changed files with 33 additions and 1 deletions

View File

@ -1667,6 +1667,38 @@ describe('ngc transformer command-line', () => {
`);
expect(main(['-p', path.join(basePath, 'src/tsconfig.json')])).toBe(0);
});
it('should not type check a .js files from node_modules with allowJs', () => {
write('src/tsconfig.json', `{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"noEmitOnError": true,
"allowJs": true,
"declaration": false
},
"files": ["test-module.ts"]
}`);
write('src/test-module.ts', `
import {Component, NgModule} from '@angular/core';
import 'my-library';
@Component({
template: 'hello'
})
export class HelloCmp {}
@NgModule({
declarations: [HelloCmp],
})
export class MyModule {}
`);
write('src/node_modules/t.txt', ``);
write('src/node_modules/my-library/index.js', `
export someVar = 1;
export someOtherVar = undefined + 1;
`);
expect(main(['-p', path.join(basePath, 'src/tsconfig.json')])).toBe(0);
});
});
describe('formatted messages', () => {