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

fix(types): props type is incompatible with setup returned type #7338

Merged
merged 2 commits into from
Nov 9, 2023

Conversation

rudyxu1102
Copy link
Contributor

@rudyxu1102 rudyxu1102 commented Dec 13, 2022

Fixes #5885

Problem

// never
type Foo = {
    size:  'small' | 'big'
} & {
    size: number
}

@netlify
Copy link

netlify bot commented Dec 13, 2022

Deploy Preview for vuejs-coverage failed.

Name Link
🔨 Latest commit 0a98c69
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/6398a007c728960008a3c030

@netlify
Copy link

netlify bot commented Dec 13, 2022

Deploy Preview for vue-next-template-explorer failed.

Name Link
🔨 Latest commit 0a98c69
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/6398a0070e7569000932fc18

@netlify
Copy link

netlify bot commented Dec 13, 2022

Deploy Preview for vue-sfc-playground failed.

Name Link
🔨 Latest commit 0a98c69
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/6398a00732c73a0008c48e14

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 85.9 kB 32.6 kB 29.5 kB
vue.global.prod.js 132 kB 49.3 kB 44.4 kB

Usages

Name Size Gzip Brotli
createApp 47.9 kB 18.8 kB 17.2 kB
createSSRApp 50.6 kB 19.9 kB 18.2 kB
defineCustomElement 50.3 kB 19.6 kB 17.9 kB
overall 61.2 kB 23.7 kB 21.6 kB

@pikax pikax added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready to merge The PR is ready to be merged. labels Nov 3, 2023
@yyx990803 yyx990803 merged commit 0e1e8f9 into vuejs:main Nov 9, 2023
10 checks passed
@haoqunjiang
Copy link
Member

This PR seems to have caused a regression in test-utils types:
https://github.com/vuejs/ecosystem-ci/actions/runs/6822057901/job/18553448341#step:7:3107

@pikax
Copy link
Member

pikax commented Nov 10, 2023

@sodatea I'll have a look and fix the regression

@pikax
Copy link
Member

pikax commented Nov 13, 2023

Fix here vuejs/test-utils#2240

@haoqunjiang
Copy link
Member

The latest vuetify ecosystem-ci failure is also caused by this PR: https://github.com/vuejs/ecosystem-ci/actions/runs/6873130528/job/18696834234#step:7:1112

@pikax
Copy link
Member

pikax commented Nov 15, 2023

@sodatea Interesting I think their usage is incorrect 🤔

The error is because defineComponent({ ...{} as any }) cannot be used in conjunction with Component

declare function test(O: Component): void

test(
  // @ts-expect-error errors here
  defineComponent({
    ...({} as any)
  })
)

test(
  // works
  defineComponent({
    ...({} as Record<string, any>)
  })
)

const c =  defineComponent({
    ...({} as any)
  })
  
// works
test(c)

I suppose this happens because because typescript can't simply infer the correct type, IMO casting as any there is not very good, since it's telling the defineComponent it can be anything, like functions, symbol, number, etc...

Not sure if we should even support that tbh.

/cc @KaelWD

EDIT: This is the overload before this PR it would pick up:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready to merge The PR is ready to be merged. scope: types
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Type is lost when returning a property from setup that uses the name of a prop.
4 participants