Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1ac85ee

Browse filesBrowse files
authored
Fix false positives for type def with script setup in ts no-unused-vars (#191)
1 parent fde53d1 commit 1ac85ee
Copy full SHA for 1ac85ee

File tree

Expand file treeCollapse file tree

3 files changed

+25
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-0
lines changed

‎src/script-setup/scope-analyzer.ts

Copy file name to clipboardExpand all lines: src/script-setup/scope-analyzer.ts
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ function analyzeUsedInTemplateVariables(
205205

206206
variable.references.push(reference)
207207
reference.resolved = variable
208+
209+
if (reference.isTypeReference) {
210+
// @typescript-eslint/no-unused-vars treats type references at the same position as recursive references,
211+
// so without this flag it will be marked as unused.
212+
;(variable as any).eslintUsed = true
213+
}
208214
}
209215

210216
function processVExpressionContainer(node: VExpressionContainer) {
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"@typescript-eslint/no-unused-vars": "error"
4+
}
5+
}
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script setup lang="ts">
2+
import MyComponent from "./components/MyComponent.vue";
3+
interface Foo {
4+
foo?: string;
5+
}
6+
type Bar = string;
7+
</script>
8+
9+
<template>
10+
<MyComponent
11+
:foo="{} as Foo"
12+
:bar="'s' as Bar"
13+
/>
14+
</template>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.