refactor(compiler-cli): make template parsing errors into diagnostics (#38576)
Previously, the compiler was not able to display template parsing errors as true `ts.Diagnostic`s that point inside the template. Instead, it would throw an actual `Error`, and "crash" with a stack trace containing the template errors. Not only is this a poor user experience, but it causes the Language Service to also crash as the user is editing a template (in actuality the LS has to work around this bug). With this commit, such parsing errors are converted to true template diagnostics with appropriate span information to be displayed contextually along with all other diagnostics. This majorly improves the user experience and unblocks the Language Service from having to deal with the compiler "crashing" to report errors. PR Close #38576
This commit is contained in:

committed by
Andrew Scott

parent
1c2ccfed4d
commit
9bf32c4dcb
@ -101,7 +101,14 @@ export function parseR3(
|
||||
['onEvent'], ['onEvent']);
|
||||
const bindingParser =
|
||||
new BindingParser(expressionParser, DEFAULT_INTERPOLATION_CONFIG, schemaRegistry, null, []);
|
||||
return htmlAstToRender3Ast(htmlNodes, bindingParser);
|
||||
const r3Result = htmlAstToRender3Ast(htmlNodes, bindingParser);
|
||||
|
||||
if (r3Result.errors.length > 0) {
|
||||
const msg = r3Result.errors.map(e => e.toString()).join('\n');
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
return r3Result;
|
||||
}
|
||||
|
||||
export function processI18nMeta(
|
||||
|
Reference in New Issue
Block a user