mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
4a53b7f36b
When the Angular compiler emits a diagnostic in a template file, it forces TypeScript to parse that template. Templates are not TypeScript, so this parse finds a bunch of parsing errors, which Angular then ignores and we show the diagnostic anyways because we have more context. This can lead to strange behavior in TypeScript because templates are so weird that it can break the parser and crash the whole compiler. For example, certain Angular templates can encounter failures fixed by microsoft/TypeScript#45987, which are not easily debuggable and require a TS upgrade to fix. This commit introduces logic to handle the error gracefully, by falling back to report the template error on the component class itself. The diagnostic is extended to still reference the template location and includes the failure's stack trace, to allow the parsing failure to be reported to TypeScript (as parsing should in theory not cause a crash). Closes #43970 PR Close #44001
Angular
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in Angular documentation.
License: MIT