Closed ThomasOrlita closed 2 years ago
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.
The patch has been released with version 3.5.1
. Please verify that the issue is indeed fixed.
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} />
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?
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. 👍
Does release v3.5.2
fix the issue?
Yes, it's fixed now. Thank you!
I'm using the Autocomplete element, but TypeScript is complaining that the
getOptions
property doesn't exist.Attractions 3.5.0 Svelte 3.44.2 TypeScript 4.5.2