Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte 5: Reintroduce frame/pos/toString() in compiler warnings #12151

Closed
Conduitry opened this issue Jun 23, 2024 · 0 comments · Fixed by #12326
Closed

Svelte 5: Reintroduce frame/pos/toString() in compiler warnings #12151

Conduitry opened this issue Jun 23, 2024 · 0 comments · Fixed by #12326
Labels
compiler Changes relating to the compiler feature request
Milestone

Comments

@Conduitry
Copy link
Member

Describe the problem

Svelte 4 has some convenient fields on warnings that display the information in a human-readable way - but which are missing in Svelte 5. The frame contained some nearby context in the file and had a caret pointing at the position of the warning. The .toString() method was somewhat customized per type of warning, and would display some combination of the message, the filename, the line/column, the nearby code in the component, etc.

Describe the proposed solution

The simplest for consumers would be for the frame, pos, and toString() to be reimplemented as they were in v4, but there are other options here, too.

Importance

nice to have

@Conduitry Conduitry added feature request compiler Changes relating to the compiler labels Jun 23, 2024
@Conduitry Conduitry added this to the 5.0 milestone Jun 23, 2024
dummdidumm added a commit that referenced this issue Jul 6, 2024
This aligns warning and error objects to contain the same properties and have their toString methods return the same shape. It also adds back the `frame` property that got lost in the Svelte 4->5 transition. The only difference to Svelte 4 now is a slightly adjusted toString property (which is consistent between warnings and errors now) and a `position` property that contains a tuple of start/end offsets instead of a `pos` property only containing the start offset

closes #12151
dummdidumm added a commit that referenced this issue Jul 6, 2024
This aligns warning and error objects to contain the same properties and have their toString methods return the same shape. It's implemented by warnings becoming class objects, too, and sharing the same base class with errors. It also adds back the `frame` property that got lost in the Svelte 4->5 transition. The only difference to Svelte 4 now is a slightly adjusted toString property (which is consistent between warnings and errors now) and a `position` property that contains a tuple of start/end offsets instead of a `pos` property only containing the start offset

closes #12151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Changes relating to the compiler feature request
Projects
None yet
1 participant