Skip to content

TypeScript: priority of typings seems wrong #1836

@bugproof

Description

@bugproof

Describe the bug

When passing through props from e.g. <li> element

https://github.com/sveltejs/svelte/blob/7e6acbece31fbd68e2c07e37f3c849c405eb6983/elements/index.d.ts#L796-L798

export interface HTMLLiAttributes extends HTMLAttributes<HTMLLIElement> {
	value?: string | string[] | number | undefined | null;
}

it doesn't seem to be possible to override the default typing for value e.g. consider this component that defaults to rendering as <li> element

https://github.com/rgossiaux/svelte-headlessui/blob/master/src/lib/components/listbox/ListboxOption.svelte#L7

the value there expects unknown type but when you try to assign any/unknown type you get an error because index.d.ts typing takes precendence.

Reproduction

The easiest way to reproduce is to use headless ui fork for Svelte: https://svelte-headlessui.goss.io/docs/listbox and copy paste the basic example.

Expected behaviour

It shouldn't give typescript error

System Info

  • OS: Windows
  • IDE: VSCode

Which package is the issue about?

None

Additional Information, eg. Screenshots

sveltejs/svelte#7649

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions