wonderful-panda/vue-tsx-support

Allow create component from (Props, Events, ScopedSlots) tuples

Opened this issue · 0 comments

Technically, Events are a relationship with Props:

interface SProps {
  multiple: false
  value: T
}

interface MProps {
  multiple: true
  value: T[]
}

interface SEvents {
  onInput: (v: T) =>void
}

interface MEvents {
  onInput: (v: T[]) =>void
}

type Props = SProps | MProps

type Events = SEvents | MEvents

class A extends tsx.Component<Props, Events> {
}

const S = <A multiple={false} value={1} onInput={/**/} />
const M = <A multiple={true} value={[1]} onInput={/**/} />

In that case, we could inference type of value from 'multiple' property, but seems no idea about onInput event ((v: any) =>any on ts@next), Even though it works, the type of that should be(v: T | T[]) =>void, that is not the type we expected,

Could we provide a new API to create relationship events from props? Maybe that is helpful to that case
eg:

type SArgs = [SProps, SEvents]
type MArgs = [MProps, MProps]

class A extends tsx.Or<SArgs , MArgs> {
}