-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript: Autocomplete shows more options than a component has #1453
Comments
According to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio: Additional attributes Please note that "the common attributes shared by all input elements". Some users may be using attributes that you may not be using. By extending it you can use By doing extending it, you won't get any error when you run So |
When you take a look at the attributes of input you can find the following sentence:
Below the sentence you find a table including these rows: So, from what I understand e.g. a radio input has the global attributes and the ones in the table where type is |
That's right. But svelte doesn't provide specific types for radio, checkbox etc. They belong to |
Sadly, that's true. I created an issue in the svelte repo: sveltejs/svelte#13447. Maybe they will add some types. |
Hello, Another solution would be to use For example for radio : interface $$Props extends Omit<HTMLInputAttributes,
'accept' | 'alt' | 'autocapitalize' | 'autocomplete' | 'capture' |
'dirname' | 'formaction' | 'formenctype' | 'formmethod' |
'formnovalidate' | 'formtarget' | height' | 'max' | 'maxlength' |
'min' | 'minlength' | 'multiple' | 'pattern' | 'placeholder' |
'popovertarget' | 'popovertargetaction' | 'readonly' |
'size' | 'src' | 'step' | 'width'> { |
Using v0.46.20 my IDE shows more options for components than they should have. Here an example for
Radio
:The cause is that
$$Props
insrc/lib/forms/Radio.svelte
is extendingHTMLInputAttributes
:interface $$Props extends HTMLInputAttributes {
The problem is that a radio input doesn't have such attributes like
max
ormaxLength
and if the IDE makes wrong suggestions you would always have to look into documentation to be sure that a component really has an attribute.I suggest to define
$$Props
like this (again an example forRadio
):So, don't extend
HTMLInputAttributes
but map the props to the attributes ofHTMLInputAttributes
. Yes, this is more work for you maintainers offlowbite-svelte
but it makes using your library easier.The text was updated successfully, but these errors were encountered: