Repository navigation
Conversation
…rrors Errors raised while transforming the parsed template into the R3 AST, such as `@for loop must have a "track" expression`, were converted to diagnostics with only their message, dropping the span they carry. For a `templateUrl` component, `vite build` then pointed at the component's `.ts` file with no hint of where the error was in the HTML. Convert them with `html_parse_error_diagnostic`, like HTML parse errors: `file:line:column` in the help text (and a label for an inline template that appears verbatim in the source). The function now leaves an error without a position (an expression parser error) as its message alone, a check only the linker path had. Fixes voidzero-dev#742
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #742.
A template error found after HTML parsing, such as
@for loop must have a "track" expression, was reported with only its message. For a component with atemplateUrl,vite buildthen pointed at the component's.tsfile, with nothing to say where the error was in the HTML:It now reports the position
ngcgives (broken.component.html:3:3):Root cause
Template errors come from two stages. HTML parse errors carry a position since #568:
file:line:columnin the help text, which the Vite plugin appends to the message. Errors from the HTML-to-R3 transform carry a correct span too, but it was dropped when they were converted to diagnostics. Only the linker path kept it.Changes
compile_component_full,compile_component_template,compile_template_to_js_with_optionsandcompile_template_for_hmrconvert R3 transform errors withhtml_parse_error_diagnostic, as they already do for HTML parse errors. Each uses the same template origin as its HTML-error branch, so an inline template that appears verbatim in the source also gets a label, and the HMR path reports a line and column within the template.html_parse_error_diagnosticreturns only the message for an error without a position. Expression parser errors have an empty default span; their message gives the column within the expression. This check was inline incompile_template_for_linker, which now relies on the shared one.describeDiagnosticalready appends the help text.