-
-
Notifications
You must be signed in to change notification settings - Fork 23
Add support for store access type infomation #192
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
if (reservedNames.has(nm)) continue; | ||
|
||
this.appendScriptWithoutOffset( | ||
`declare let $${nm}: Parameters<Parameters<(typeof ${nm})["subscribe"]>[0]>[0];`, |
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.
What if there is already an identifier named $nm
or it's already declared by the user manually?
This could be uncommon, but before this PR this could happen if the user want to workaround this issue, then this PR would break that.
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.
I checked the edge case and it didn't seem to be a problem.
https://github.com/ota-meshi/svelte-eslint-parser/blob/store-type/tests/fixtures/parser/ast/ts-store01-type-output.svelte
Also, the svelte compiler doesn't seem to allow you to declare variables that start with $ yourself.
<script>
let name = 'world';
const $n = name
</script>
<h1>Hello {name}!</h1>
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.
Does script
with lang="ts"
+ user defined declare const $n: xxx
works the same?
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.
I added a test case to check that edge case. That doesn't seem to be a problem either 😉.
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.
Wow, that is a bit of surprise to me
https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEYD2A7AzgF3gEigLnkxgEsUBzAKFElgWXS1wKNMqA
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.
OK, it should due to
tokens.length = 0
comments.length = 0
removeAllScope(node, result)
I just learned a lot from this PR!
close #191