Skip to content

chore: CompileDiagnostic no longer extends Error #13651

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

Merged
merged 1 commit into from
Oct 18, 2024
Merged

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Oct 17, 2024

Closes #13628.

Copy link

changeset-bot bot commented Oct 17, 2024

🦋 Changeset detected

Latest commit: 5e2b850

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

@dummdidumm
Copy link
Member

How does a compiler error look like in the terminal now?

@trueadm
Copy link
Contributor Author

trueadm commented Oct 18, 2024

How does a compiler error look like in the terminal now?

I don't see any difference, unless I'm missing something? I also see the InternalCompileError, which now no longer extends Error also looks fine in the terminal. Maybe it's different on Windows?

@dummdidumm
Copy link
Member

I can't check because no laptop at hand. Can you post a screenshot of a compiler error? (I think it will look a bit different, previously when a compiler error was thrown it showed the stack trace)

@trueadm
Copy link
Contributor Author

trueadm commented Oct 18, 2024

I can't check because no laptop at hand. Can you post a screenshot of a compiler error? (I think it will look a bit different, previously when a compiler error was thrown it showed the stack trace)

I was only checking warnings. I just noticed that InternalCompileError also extends CompileDiagnostic, which no longer extends Error so there might be some differences.

Before:

Screenshot 2024-10-18 at 11 17 32

After:

Screenshot 2024-10-18 at 11 17 08

To be honest, the stack trace doesn't really give the user anything as it's all internal logic anyway. So it actually looks better?

@dummdidumm
Copy link
Member

Yeah that looks better.
Wondering if that solves the original issue of the object not being properly stringified automatically (POJOs become json)

@trueadm
Copy link
Contributor Author

trueadm commented Oct 18, 2024

So should we merge this and close out that issue @Rich-Harris @dummdidumm?

@dummdidumm
Copy link
Member

I don't think it solves the original issue which was about the deserialization issue of the warning. With a class you don't get the pojo<->json capability

@paoloricciuti
Copy link
Member

I don't think it solves the original issue which was about the deserialization issue of the warning. With a class you don't get the pojo<->json capability

We can implement a toJSON method to fix it right?

@dummdidumm
Copy link
Member

AFAIK it already has one? So it doesn't seem to work?

@trueadm
Copy link
Contributor Author

trueadm commented Oct 18, 2024

It works fine for me, this is it passed over postMessage:

'{"code":"mixed_event_handler_syntaxes","message":"Mixing old (on:click) and new syntaxes for event handling is not allowed. Use only the onclick syntax","filename":"(unknown)","start":{"line":5,"column":5,"character":39},"end":{"line":7,"column":2,"character":60},"position":[39,60],"frame":"3: }}></div>\\n4: \\n5: <div on:click={() => {\\n     ^\\n6: \\n7: }}></div>"}'

If we extend Error again, then it doesn't work. So I guess we've fixed it?

@dummdidumm
Copy link
Member

Ha, crazy that not extending from Error does that - that looks good to merge then

@trueadm trueadm merged commit 894b1c3 into main Oct 18, 2024
9 checks passed
@trueadm trueadm deleted the compile-warning branch October 18, 2024 21:13
paoloricciuti added a commit that referenced this pull request Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CompileWarning extends Error
3 participants