language-tools: slot props type when reference block scope variable
Describe the bug
when slot props
is referencing a block scope variable it would have any type in the consumer
To Reproduce Steps to reproduce the behavior:
Component.svelte
<script>
let list = ['']
</script>
{#each list as value}
<slot props={value} />
{/each}
consumer
<Component let:name></Component>
where name
has a type of any
Expected behavior have correct type
Screenshots
If applicable, add screenshots to help explain your problem.
System (please complete the following information):
- OS: Windows
- IDE: VSCode
- Plugin/Package: Svelte for VSCode, svelte2tsx
Additional context got transform to
<></>;function render() {
let list = [''];
; <>
{(list).map((value) => <>
<slot props={value} />
</>)}</> return { props: {}, slots: {default: {props:value}} }} export default class { $$prop_def = __sveltets_partial(render().props) $$slot_def = render().slots }
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (16 by maintainers)
Maybe this could really work in a generic way:
#each
, do(__svelte_ts_unwrappAttr(list))
#await
, do the same but with__svelte_ts_unwrapPromiseLike(promise)
I think we can still provide the way to manually type components even if @PatrickG’s solution is easier to implement. It can serve as a fallback for edge-case, bug, or even manually type the event.
And we also need to check if the expression references another slot props. The whole process it’s so tedious I think it’s better off just don’t support it and provide a way to let the user manually defined its type.