Open
Description
Describe the bug
svelte-check
expects an alt
attribute for img
Elements.
But when adding the alt
attribute with an action svelte-check
still complains, that the alt
attribute is needed.
The action has an ActionReturn<undefined, { alt: string }>
type telling svelte-check
that the alt
attribute is added when this action is used.
Am I using the ActionReturn
type wrongly? Since I am also getting another TypeScript error
Reproduction
<script lang="ts">
import { type ActionReturn } from "svelte/action";
function action(
node: HTMLImageElement,
): ActionReturn<undefined, { alt: string; src: string }> {
node.src = "file://image";
node.alt = "local file";
return {};
}
</script>
<img use:action />
Logs
debug.svelte:13:1
Warn: A11y: <img> element should have an alt attribute (svelte)
<img use:action />
debug.svelte:13:4
Error: Argument of type '{}' is not assignable to parameter of type 'Omit<HTMLImgAttributes, never> & HTMLAttributes<any> & { alt: string; src: string; }'.
Type '{}' is missing the following properties from type '{ alt: string; src: string; }': alt, src (ts)
<img use:action />
System Info
System:
OS: Linux 6.5 Fedora Linux 39 (Container Image)
CPU: (16) x64 AMD Ryzen 7 7840U w/ Radeon 780M Graphics
Memory: 17.35 GB / 30.53 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 20.10.0 - /usr/bin/node
npm: 10.2.3 - /usr/bin/npm
npmPackages:
svelte: * => 4.2.8
Severity
annoyance