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

fix: avoid state_referenced_locally warning within type annotations #11638

Merged
merged 7 commits into from
May 15, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented May 15, 2024

Fixes #11614

Copy link

changeset-bot bot commented May 15, 2024

🦋 Changeset detected

Latest commit: 3935277

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

@Rich-Harris
Copy link
Member

this feels wrong, pretty sure we should be bailing in is_reference so that this isn't treated as a reference in the first place? this is like obj = { count: 42 } treating count as a reference

@Rich-Harris
Copy link
Member

A wrinkle here is that is_reference is an external module that really shouldn't be TS-aware. Ideally, we'd solve this by not visiting children of TSWhatever nodes, but that doesn't work with our visitor merging logic.

Conclusion: we should retire the visitor merging logic instead of having single cross-functional visitors. I've been meaning to work on that for a while anyway. It'll be a bit noisy though so we should probably try and close as much of the PR queue as possible first

@Rich-Harris
Copy link
Member

marking as draft until we can take that on, to reduce noise

@Rich-Harris Rich-Harris marked this pull request as draft May 15, 2024 16:55
@trueadm
Copy link
Contributor Author

trueadm commented May 15, 2024

@Rich-Harris I first started off be pulling out is_reference and changing it to work like you mentioned, but then I realised that this probably was just an issue with this particular warning.

@dummdidumm
Copy link
Member

We're supposed to strip all TS traces at https://github.com/sveltejs/svelte/blob/main/packages/svelte/src/compiler/index.js#L37 - wonder why it doesn't work for this? The real fix probably lies in there.

@trueadm
Copy link
Contributor Author

trueadm commented May 15, 2024

We're supposed to strip all TS traces at https://github.com/sveltejs/svelte/blob/main/packages/svelte/src/compiler/index.js#L37 - wonder why it doesn't work for this? The real fix probably lies in there.

Seems to be missing TSTypeAnnotation and a bunch of others.

@trueadm trueadm marked this pull request as ready for review May 15, 2024 20:33
@trueadm
Copy link
Contributor Author

trueadm commented May 15, 2024

I applied a better fix, thanks @dummdidumm

@trueadm trueadm merged commit 053159b into main May 15, 2024
8 checks passed
@trueadm trueadm deleted the fix-state_referenced_locally branch May 15, 2024 21:17
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.

state_referenced_locally warning should skip type declarations
3 participants