Skip to content
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

Autocomplete: Property 'getOptions' does not exist on type 'IntrinsicAttributes & AutocompleteProps' #325

Closed
ThomasOrlita opened this issue Nov 20, 2021 · 7 comments · Fixed by #326

Comments

@ThomasOrlita
Copy link

I'm using the Autocomplete element, but TypeScript is complaining that the getOptions property doesn't exist.

image

Attractions 3.5.0
Svelte 3.44.2
TypeScript 4.5.2

@aabounegm
Copy link
Collaborator

Thank you for filing this issue. The problem was due to updating to a sveld without checking the changelog first 😅, which caused a type import (the one being extended by Autocomplete) to be invalid. A pull request fixing this issue is in progress.

@aabounegm
Copy link
Collaborator

The patch has been released with version 3.5.1. Please verify that the issue is indeed fixed.

@ThomasOrlita
Copy link
Author

Thanks for the quick update!

Now it however lights up with a different error:

Type '(text: any) => AsyncGenerator<({ name: any; details: string; } | { name: string; details?: undefined; })[], void, unknown>' is not assignable to type 'OptionsGetter'.
  Property '[Symbol.iterator]' is missing in type 'AsyncGenerator<({ name: any; details: string; } | { name: string; details?: undefined; })[], void, unknown>' but required in type 'Generator<Promise<Option[]>, never, never>'.

This is the code (from the demo):

<script lang="ts">
  import { Autocomplete } from 'attractions';

  async function* getOptions(text) {
    yield [{ name: text, details: 'Optional' }, { name: `it highlights the match: ${text}` }];
  }
</script>

<Autocomplete getOptions={getOptions} />

@aabounegm
Copy link
Collaborator

Hmm. I'm not so familiar with generator functions' types, but do you think

type OptionsGetter = (q: string) => AsyncGenerator<Option[], void, void>;

would be more appropriate?

@aabounegm aabounegm reopened this Nov 20, 2021
@ThomasOrlita
Copy link
Author

Hmm. I'm not so familiar with generator functions' types, but do you think

type OptionsGetter = (q: string) => AsyncGenerator<Option[], void, void>;

would be more appropriate?

I think this type should work. 👍

@aabounegm
Copy link
Collaborator

Does release v3.5.2 fix the issue?

@ThomasOrlita
Copy link
Author

Yes, it's fixed now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants