-
-
Notifications
You must be signed in to change notification settings - Fork 23
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: recognize script as module for Typescript type checking #604
Conversation
🦋 Changeset detectedLatest commit: 6055811 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 |
@@ -95,7 +95,6 @@ | |||
"eslint-plugin-regexp": "^2.7.0", | |||
"eslint-plugin-svelte": "^2.46.1", | |||
"eslint-plugin-yml": "^1.15.0", | |||
"estree-walker": "^3.0.3", |
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 think we don't use this dependency.
@@ -380,7 +398,7 @@ function analyzeRuneVariables( | |||
// See https://github.com/sveltejs/svelte/blob/41b5cd6f5daae3970a9927e062f42b6b62440d16/packages/svelte/types/index.d.ts#L2615 | |||
case "$props": { | |||
// Use type parameters to avoid `@typescript-eslint/no-unsafe-assignment` errors. | |||
appendDeclareFunctionVirtualScripts(globalName, ["<T>(): T"]); | |||
appendDeclareFunctionVirtualScripts(globalName, ["(): any"]); |
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.
Now $props
doesn't have generics.
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.
But 1 test is failed, so I reverted it.
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.
Yeah, this is intentionally typed differently than Svelte core.
Pull Request Test Coverage Report for Build 12102873057Details
💛 - Coveralls |
// When performing type checking on TypeScript code that is not a module, the error `Cannot redeclare block-scoped variable 'xxx'`. occurs. To fix this, add an `export`. | ||
// see: https://github.com/sveltejs/svelte-eslint-parser/issues/557 | ||
if (!hasExportDeclaration(result.ast)) { | ||
appendDummyExport(ctx); | ||
} |
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.
Here is main part of this PR.
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.
LGTM!
nice! |
close: #557
This PR adjusts the script to always be recognized as a module. This ensures that the error “Cannot redeclare block-scoped variable ‘xxx’” does not occur.