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

feat: prioritize inferring property type from value #335

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yangmingshan
Copy link
Contributor

参考:#332 (comment)

boolean 类型不能优先从 value 推导,否则推导出来的类型是 true 或者 false,而非 boolean

@lv-z-l
Copy link
Contributor

lv-z-l commented Oct 14, 2024

boolean 类型不能优先从 value 推导,否则推导出来的类型是 true 或者 false,而非 boolean

我可能没get到上面这句话,目前正常推导出来就是boolean
image

@yangmingshan
Copy link
Contributor Author

@lv-z-l 我没有在说你的修改有问题。我是在解释为什么我要改为:

type FullPropertyToData<T extends AllFullProperty> = T['type'] extends null | BooleanConstructor ? ValueType<T['type']> : unknown extends T['value'] ? ValueType<T['type']> : T['value']

而非:

type FullPropertyToData<T extends AllFullProperty> = T['type'] extends null ? ValueType<T['type']> : unknown extends T['value'] ? ValueType<T['type']> : T['value']

注意二者 BooleanConstructor 的差别。

@lv-z-l
Copy link
Contributor

lv-z-l commented Oct 15, 2024

get

@yangmingshan
Copy link
Contributor Author

@SgLy 大佬麻烦看一下

@SgLy SgLy self-assigned this Oct 17, 2024
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.

3 participants