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: allow use default factory for primitive types #5939

Merged
merged 2 commits into from May 23, 2022

Conversation

cawa-93
Copy link
Contributor

@cawa-93 cawa-93 commented May 17, 2022

Fix #5938

@yyx990803
Copy link
Member

Ah ok I got confused myself. Can you add a test case in setupHelpers.test-d.ts?

@PatrickChen928
Copy link

I'm confused, why not use
declare type InferDefault<P, T> = T | ((props: P) => T)
instead of
declare type InferDefault<P, T> = T extends null | number | string | boolean | symbol | Function ? T | ((props: P) => T) : (props: P) => T;.
because of never?

@netlify
Copy link

netlify bot commented May 19, 2022

Deploy Preview for vuejs-coverage failed.

Name Link
🔨 Latest commit dfaeca1
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/6285de5c7c06430008ec4f77

@cawa-93
Copy link
Contributor Author

cawa-93 commented May 19, 2022

@ChpShy

I'm confused, why not use declare type InferDefault<P, T> = T | ((props: P) => T) instead of declare type InferDefault<P, T> = T extends null | number | string | boolean | symbol | Function ? T | ((props: P) => T) : (props: P) => T;. because of never?

According to docs:

Object or array defaults must be returned from a factory function. The function receives the raw props received by the component as the argument.

@PatrickChen928
Copy link

I'm confused, why not use declare type InferDefault<P, T> = T | ((props: P) => T) instead of declare type InferDefault<P, T> = T extends null | number | string | boolean | symbol | Function ? T | ((props: P) => T) : (props: P) => T;. because of never?

According to docs:

Object or array defaults must be returned from a factory function. The function receives the raw props received by the component as the argument.

@cawa-93
a... I see , thanks very much~

@yyx990803 yyx990803 merged commit b546282 into vuejs:main May 23, 2022
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.

withDefaults() has type error when used default factory for type
3 participants