-
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: relax component constructor type (#2524)
Since , we're no longer adding the `[evt: string]: CustomEvent<any>` index signature to components in runes mode not using `createEventDispatcher`. This revealed a type bug in our `ATypedSvelteComponent` type. It was to restricting, because TypeScript will resolve the empty event object to a handler with callback type `never`, which then means the `__sveltets_2_ensureComponent` generic no longer picks the right type, resulting in generics not being resolved properly. Fix this by relaxing the constraints. Fixes #2523
- Loading branch information
1 parent
fc2144b
commit 4dfb988
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
.../plugins/typescript/features/diagnostics/fixtures/generics-runes.v5/ValueComponent.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script lang="ts" generics="T"> | ||
let { value, defaultValue }: { value: T; defaultValue?: T } = $props(); | ||
</script> | ||
|
||
{value} | ||
{defaultValue} |
19 changes: 19 additions & 0 deletions
19
...r/test/plugins/typescript/features/diagnostics/fixtures/generics-runes.v5/expectedv2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ | ||
{ | ||
"code": 2322, | ||
"message": "Type 'number' is not assignable to type 'string'.", | ||
"range": { | ||
"end": { | ||
"character": 36, | ||
"line": 10 | ||
}, | ||
"start": { | ||
"character": 24, | ||
"line": 10 | ||
} | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"tags": [] | ||
} | ||
] |
11 changes: 11 additions & 0 deletions
11
...rver/test/plugins/typescript/features/diagnostics/fixtures/generics-runes.v5/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import ValueComponent from './ValueComponent.svelte'; | ||
let value = $state("test"); | ||
</script> | ||
|
||
<!-- ok --> | ||
<ValueComponent {value} defaultValue={"foo"} /> | ||
|
||
<!-- error --> | ||
<ValueComponent {value} defaultValue={1} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters