Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

How To Use Types In Props #27

Open
bekalshenoy opened this issue Apr 28, 2020 · 2 comments
Open

How To Use Types In Props #27

bekalshenoy opened this issue Apr 28, 2020 · 2 comments

Comments

@bekalshenoy
Copy link

The Documentation Is Limited For How To Use Types In Props. It Can Help Me To Use Interface As A Type For A Prop Instead Of Using Object By Default.

@ycmjason
Copy link

ycmjason commented Apr 28, 2020

Don't think it relates to the composition api itself. But I suppose you can type the validator.

defineComponent({
  props: {
    magic: (x: Magic) => true
  }
})

@jefrydco
Copy link

@bekalshenoy You can type it this way:

type ComponentProps = {
  value: string
}

defineComponent<ComponentProps>({
  // Props will automatically has `ComponentProps` type
  setup(props) {}
})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants