Skip to content

Commit 3119299

Browse files
authored
feat: improve props type (#569)
1 parent 9f26a96 commit 3119299

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.changeset/early-lobsters-repeat.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": minor
3+
---
4+
5+
feat: improve props type

src/parser/converts/attr.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ function buildAttributeType(
293293
return null;
294294
}
295295
const elementName = ctx.elements.get(element)!.name;
296-
const componentPropsType = `import('svelte').ComponentProps<${elementName}>`;
296+
const componentPropsType = `import('svelte').ComponentProps<typeof ${elementName}>`;
297297
return conditional({
298298
check: `'${attrName}'`,
299299
extends: `infer PROP`,
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script lang="ts">
2-
import Component from './ts-event03-input.svelte'; // Component: __sveltets_2_IsomorphicComponent<$$ComponentProps, { [evt: string]: CustomEvent<any>; }, {}, Record<string, any>, string>
2+
import Component from './ts-event03-input.svelte'; // Component: Component<$$ComponentProps, {}, "">
33
</script>
44

5-
<Component onfoo="{e=>{ // Component: __sveltets_2_IsomorphicComponent<$$ComponentProps, { [evt: string]: CustomEvent<any>; }, {}, Record<string, any>, string>, e: { detail: number; }
5+
<Component onfoo="{e=>{ // Component: Component<$$ComponentProps, {}, "">, e: { detail: number; }
66
// e.detail is number
77
e.detail; // e.detail: number
88
}}" />

0 commit comments

Comments
 (0)