Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Kingwl opened this issue Mar 18, 2019 · 0 comments
Open

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

Kingwl opened this issue Mar 18, 2019 · 0 comments

Comments

@Kingwl
Copy link

Kingwl commented Mar 18, 2019

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> {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant