-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: align warning and error objects, add frame property #12326
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
Conversation
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
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
🦋 Changeset detectedLatest commit: 263610d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
||
/** @typedef {{ start?: number, end?: number }} NodeLike */ | ||
|
||
export class InternalCompileError extends Error { | ||
export class InternalCompileError extends CompileDiagnostic { | ||
name = 'CompileError'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side note: I would've called this "CompilerError" (note the additional r). Is "compile error" more correct? I stumble over that mentally each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error is comming from the compiler, so I would call it a CompilerError. Not meaning there is something is wrong with the compiler, but the an error has been raised from compiler. thoughts?
Alternative to #12325 which consolidates things further by having a common base class for both warnings and errors. (Personally I prefer this PR right here over the other one)
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 aposition
property that contains a tuple of start/end offsets instead of apos
property only containing the start offsetcloses #12151
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint