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

types(runtime-core): defineComponent options #5416

Merged
merged 2 commits into from May 6, 2022

Conversation

Zclhlmgqzc
Copy link
Contributor

fix #3796

  const props = {
    a: Number
  }
  const MyComponent = defineComponent({
    props,
    provide() {
      return {}
    },
    render() {
      return null
    }
  })
  expectType<typeof props>(MyComponent.props)
  expectType<() => {}>(MyComponent.provide)
  expectType<() => null>(MyComponent.render)
  expectType<Function | undefined>(defineComponent({}).render)

@netlify
Copy link

netlify bot commented Feb 12, 2022

Deploy Preview for vuejs-coverage ready!

Name Link
🔨 Latest commit e9042e0
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/6274e72b8437a10009f127eb
😎 Deploy Preview https://deploy-preview-5416--vuejs-coverage.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Feb 12, 2022

Deploy Preview for vue-sfc-playground ready!

Name Link
🔨 Latest commit e9042e0
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/6274e72bceb07200087d1275
😎 Deploy Preview https://deploy-preview-5416--vue-sfc-playground.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Feb 12, 2022

Deploy Preview for vue-next-template-explorer ready!

Name Link
🔨 Latest commit e9042e0
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/6274e72bb44d6c000afa700d
😎 Deploy Preview https://deploy-preview-5416--vue-next-template-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Member

@pikax pikax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, just a few comments.

It would be nice to also have tests to the other overloads, just to make sure we are passing the correct options to other overloads.

The goal of DefineComponent is to hold all the type from defineComponent, appending types per defineComponent return will make it harder to extract generics

packages/runtime-core/src/apiDefineComponent.ts Outdated Show resolved Hide resolved
packages/runtime-core/src/component.ts Outdated Show resolved Hide resolved
packages/runtime-core/src/componentOptions.ts Outdated Show resolved Hide resolved
test-dts/defineComponent.test-d.tsx Show resolved Hide resolved
@Zclhlmgqzc Zclhlmgqzc force-pushed the types/defineComponent-options branch from 3ba970c to 9e2f228 Compare April 10, 2022 13:02
@yyx990803 yyx990803 merged commit 98b821d into vuejs:main May 6, 2022
iwusong pushed a commit to iwusong/core that referenced this pull request May 13, 2022
yyx990803 added a commit that referenced this pull request May 20, 2022
This is necessary for compatibility w/ tsc-generated component types
using DefineComponent.

revert #5416
reopen #3796
fix #5967
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.

typing defineComponent props
3 participants