Description
🐞 Bug report
Command (mark with an x
)
- [ ] new
- [ ] build
- [ x ] serve
- [ x ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
No.
Description
Handling only syntax errors when it is not a first run
It seems that AngularCompilerPlugin
handles both syntactic and semantic errors on first run, but it handles only syntax errors when it is not the first run.
angular-cli/packages/ngtools/webpack/src/angular_compiler_plugin.ts
Lines 1272 to 1273 in 95776fe
This lead to the following inconsistency behavior when executing ng serve
:
First run
- Add the code below to
app.component.ts
:
public ngOnInit() {
const x:number = '10';
console.log('============ x = ', x);
}
- Execute
ng serve
Actual behavior:
ERROR in src/app/app.component.ts:12:11 - error TS2322: Type '"10"' is not assignable to type 'number'.
12 const x:number = '10';
「wdm」: Failed to compile.
Not a first run
- Execute
ng serve
- Add the code below to
app.component.ts
:
public ngOnInit() {
const x:number = '10';
console.log('============ x = ', x);
}
Actual behavior:
wdm」: Compiled successfully.
ERROR in src/app/app.component.ts(12,11): error TS2322: Type '"10"' is not assignable to type 'number'.
As it can be seen, the webpack
compilation is not successful on first run but it is fine when it is not the first run. I'm wondering if this is the intended behavior and what is the reason for that behavior.
Currently we're relying on AngularCompilerPlugin
and in case it is intended behavior, is it possible to introduce an option so the diagnostics mode can be forced? That will give us the ability to handle both syntax and semantic errors regardless if it is first run or not.
🔬 Minimal Reproduction
🔥 Exception or Error
🌍 Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 8.3.12
Node: 10.13.0
OS: darwin x64
Angular: 8.2.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.803.12
@angular-devkit/build-angular 0.803.12
@angular-devkit/build-optimizer 0.803.12
@angular-devkit/build-webpack 0.803.12
@angular-devkit/core 8.3.12
@angular-devkit/schematics 8.3.12
@angular/cli 8.3.12
@ngtools/webpack 8.3.12
@schematics/angular 8.3.12
@schematics/update 0.803.12
rxjs 6.4.0
typescript 3.5.3
webpack 4.39.2
Anything else relevant?