Skip to content

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

Closed
pikax wants to merge 3 commits intovuejs:mainfrom
pikax:prop_interface_type
Closed

[WIP] types(defineComponent): support passing Prop interface to defineComponent#3049
pikax wants to merge 3 commits intovuejs:mainfrom
pikax:prop_interface_type

Conversation

@pikax
Copy link
Copy Markdown
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