Skip to content

Commit 9dddc36

Browse files
feat: update type of $props rune (#510)
Co-authored-by: Yosuke Ota <[email protected]>
1 parent 04cf54c commit 9dddc36

31 files changed

+5911
-6041
lines changed

.changeset/smooth-elephants-mate.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": patch
3+
---
4+
5+
feat: update type of $props rune

explorer-v2/src/lib/MonacoEditor.svelte

+5-2
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,13 @@
238238
239239
{#await loading}
240240
{#if started}
241-
<div class="eslint-editor-monaco-root eslint-editor-monaco-root--wait" in:loadingTypewriter />
241+
<div
242+
class="eslint-editor-monaco-root eslint-editor-monaco-root--wait"
243+
in:loadingTypewriter
244+
></div>
242245
{/if}
243246
{:then}
244-
<div bind:this={rootElement} class="eslint-editor-monaco-root" />
247+
<div bind:this={rootElement} class="eslint-editor-monaco-root"></div>
245248
{/await}
246249
247250
<style>

explorer-v2/src/routes/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
position: relative;
1515
height: calc(100vh - 64px);
1616
}
17-
.main > * {
17+
.main > :global(*) {
1818
position: relative;
1919
width: 100%;
2020
height: 100%;

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
4848
},
4949
"peerDependencies": {
50-
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.94"
50+
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.112"
5151
},
5252
"peerDependenciesMeta": {
5353
"svelte": {
@@ -105,7 +105,7 @@
105105
"prettier-plugin-svelte": "^3.2.2",
106106
"rimraf": "^5.0.5",
107107
"semver": "^7.6.0",
108-
"svelte": "^5.0.0-next.94",
108+
"svelte": "^5.0.0-next.112",
109109
"svelte2tsx": "^0.7.6",
110110
"typescript": "~5.4.4",
111111
"typescript-eslint-parser-for-extra-files": "^0.6.0"

src/parser/converts/element.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export function* convertChildren(
211211
continue;
212212
}
213213

214-
throw new Error(`Unknown type:${(child as any).type}`);
214+
throw new Error(`Unknown type:${child.type}`);
215215
}
216216
}
217217

src/parser/typescript/analyze/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ function analyzeRuneVariables(
354354
}
355355
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2655
356356
case "$props": {
357-
appendDeclareFunctionVirtualScripts(globalName, ["<T>(): T"]);
357+
appendDeclareFunctionVirtualScripts(globalName, ["(): any"]);
358358
break;
359359
}
360360
// See https://github.com/sveltejs/svelte/blob/dfc55c18f010f620b966e13eb0ad1f9791b5798f/packages/svelte/types/index.d.ts#L2666
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<script lang="ts">
2-
type MyProps = {}
3-
let { a, b, c, ...everythingElse } = $props<MyProps>();
2+
type MyProps = {};
3+
let { a, b, c, ...everythingElse }: MyProps = $props();
44
</script>

tests/fixtures/parser/ast/svelte5/docs/runes/08-$props-ts-no-unused-vars-result.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
"ruleId": "no-unused-vars",
44
"code": "a",
55
"line": 3,
6-
"column": 11
6+
"column": 9
77
},
88
{
99
"ruleId": "no-unused-vars",
1010
"code": "b",
1111
"line": 3,
12-
"column": 14
12+
"column": 12
1313
},
1414
{
1515
"ruleId": "no-unused-vars",
1616
"code": "c",
1717
"line": 3,
18-
"column": 17
18+
"column": 15
1919
},
2020
{
2121
"ruleId": "no-unused-vars",
2222
"code": "everythingElse",
2323
"line": 3,
24-
"column": 23
24+
"column": 21
2525
}
2626
]

0 commit comments

Comments
 (0)