Skip to content

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

Merged
merged 4 commits into from
Jul 25, 2022
Merged

Add support for store access type infomation #192

merged 4 commits into from
Jul 25, 2022

Conversation

ota-meshi
Copy link
Member

close #191

@ota-meshi ota-meshi requested a review from JounQin July 25, 2022 12:47
if (reservedNames.has(nm)) continue;

this.appendScriptWithoutOffset(
`declare let $${nm}: Parameters<Parameters<(typeof ${nm})["subscribe"]>[0]>[0];`,
Copy link
Collaborator

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.

Copy link
Member Author

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.

image

<script>
	let name = 'world';
	const $n = name
</script>

<h1>Hello {name}!</h1>

Copy link
Collaborator

@JounQin JounQin Jul 25, 2022

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?

Copy link
Member Author

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 😉.

https://github.com/ota-meshi/svelte-eslint-parser/blob/store-type/tests/fixtures/parser/ast/ts-store02-type-output.svelte

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

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!

@ota-meshi ota-meshi merged commit 2d4b9e4 into main Jul 25, 2022
@ota-meshi ota-meshi deleted the store-type branch July 25, 2022 14:26
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.

@typescript-eslint/no-unsafe-call with svelte-i18n and @typescript-eslint/recommended-requiring-type-checking
2 participants