Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Typing on props #18

Open
blocka opened this issue Jul 14, 2017 · 3 comments
Open

Typing on props #18

blocka opened this issue Jul 14, 2017 · 3 comments

Comments

@blocka
Copy link

blocka commented Jul 14, 2017

It's great that my props are recognized, but the props are all type "any", which doesn't help me much.
I see that extend is generic, and the last property is for props. But I can't make heads or tails of what to do with that.

@DanielRosenwasser
Copy link
Member

With Vue 2.5, TypeScript can understand basic prop types like

props: {
  foo: String,
  bar: Number,
  baz: Boolean,
}

@mmakrzem
Copy link

mmakrzem commented Nov 8, 2017

So there is no way to specify a prop as being of a custom type? ie:

interface IData {
  id: Number;
  name: String;
}

props: {
  foo: IData
}

@DanielRosenwasser
Copy link
Member

You could try

props: {
  foo: { default: {} as IData }
}

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