svelte-intellij icon indicating copy to clipboard operation
svelte-intellij copied to clipboard

Support SvelteComponentTyped in Component instances

Open btakita opened this issue 3 years ago • 1 comments

When a library uses SvelteComponentTyped to define props, events, & slots on a component, the plugin should index the props, events, & slots.

I have a working implementation of using SvelteComponentTyped. The state of the art seems like it's in flux.

MenuSearchBox/MenuSearchBox_T.ts

import type { SvelteComponentTyped } from 'svelte'
import type { MenuSearchBox_c } from './MenuSearchBox_c'
import type { MenuSearchBox_itemclicked_evt_I } from './MenuSearchBox_itemclicked_evt_I'
export interface MenuSearchBox_T extends SvelteComponentTyped</*@formatter:off*/
  { click_action:string },
  { itemclicked:CustomEvent<MenuSearchBox_itemclicked_evt_I> }
>/*@formatter:on*/ {
  readonly _:MenuSearchBox_c
}

MenuSearchBox/index.ts

import in_MenuSearchBox from './MenuSearchBox.svelte'
import type { MenuSearchBox_T } from './MenuSearchBox_T'
export const MenuSearchBox = in_MenuSearchBox as unknown as MenuSearchBox_T
export * from './MenuSearchBox_T'
export * from './MenuSearchBox_itemclicked_evt_I'

DependentComponent.svelte - on:itemclicked should have autocomplete & type information

<script lang=ts>
import { MenuSearchBox } from './MenuSearchBox'
import type { MenuSearchBox_itemclicked_evt_I } from './MenuSearchBox'
function onitemclicked(evt:MenuSearchBox_itemclicked_evt_I) {
  // ...
}
</script> 

<MenuSearchBox on:itemclicked={evt => onitemclicked(evt)}></MenuSearchBox>

btakita avatar Mar 12 '21 18:03 btakita

Great to see this already has some attention. Is this on the roadmap?

shaun-wild avatar Mar 09 '22 17:03 shaun-wild

Hi @tomblachut! Do you have any updates on this? Thank you

maxiruani avatar Mar 30 '23 11:03 maxiruani

Contained in WEB-58397 use the svelte language server. Please open additional issues on YouTrack.

tomblachut avatar Aug 01 '23 18:08 tomblachut