tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
485 stars 38 forks source link

Support SvelteComponentTyped in Component instances #206

Closed btakita closed 1 year ago

btakita commented 3 years ago

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>
shaun-wild commented 2 years ago

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

maxiruani commented 1 year ago

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

tomblachut commented 1 year ago

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