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

[WIP] types(defineComponent): support passing Prop interface to defineComponent #3049

Closed
wants to merge 3 commits into from

Conversation

pikax
Copy link
Member

@pikax pikax commented Jan 18, 2021

// type is correct
defineComponent<{ a?: string }>({
  props: {
    a: String
  },

  setup(props) {
    props.a
  }
})

// error type is incorrect

//@ts-expect-error invalid type on the prop definition
defineComponent<{ a: number }>({
  props: {
    a: {
      type: String,
      required: true
    }
  },

  // @ts-expect-error cannot resolve props type because of the mismatch
  setup(props) {
    props.a
  }
})
  • Type tests are missing
  • There's an issue where optional and required don't show error
  • defining prop with a type: Object will accept arrays

@pikax pikax marked this pull request as draft January 18, 2021 16:56
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

Successfully merging this pull request may close these issues.

1 participant