-
-
Notifications
You must be signed in to change notification settings - Fork 223
Closed
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.feature requestNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
I use actions a lot and have many actions that are specific for some node types (they might for example only make sense for an SVGGElement). However, currently the following fails since the SvelteAction expects the first parameter to be just an HTMLElement:
<script lang="ts">
function action(node: HTMLInputElement): {} {
console.log(node.size) // just an example of something that wouldn't type-check on HTMLElement
return {}
}
</script>
<input use:action />
This is the error:
Argument of type '(node: HTMLInputElement) => {}' is not assignable to parameter of type 'SvelteAction<[]>'.
Types of parameters 'node' and 'node' are incompatible.
Type 'HTMLElement' is missing the following properties from type 'HTMLInputElement': accept, align, alt, autocomplete, and 49 more.
Describe the solution you'd like
It would be nice if the typing for use:... would take the type of the node that the action is applied to into account.
Describe alternatives you've considered
Of course I could type-check using instanceof inside my action to have everything typecheck, but that would be more verbose and would incur a minimal but unnecessary runtime cost.
Metadata
Metadata
Assignees
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.feature requestNew feature or requestNew feature or request