Skip to content

Commit

Permalink
feat: improve props type (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Oct 13, 2024
1 parent 9f26a96 commit 3119299
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-lobsters-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": minor
---

feat: improve props type
2 changes: 1 addition & 1 deletion src/parser/converts/attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function buildAttributeType(
return null;
}
const elementName = ctx.elements.get(element)!.name;
const componentPropsType = `import('svelte').ComponentProps<${elementName}>`;
const componentPropsType = `import('svelte').ComponentProps<typeof ${elementName}>`;
return conditional({
check: `'${attrName}'`,
extends: `infer PROP`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import Component from './ts-event03-input.svelte'; // Component: __sveltets_2_IsomorphicComponent<$$ComponentProps, { [evt: string]: CustomEvent<any>; }, {}, Record<string, any>, string>
import Component from './ts-event03-input.svelte'; // Component: Component<$$ComponentProps, {}, "">
</script>

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

0 comments on commit 3119299

Please sign in to comment.