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: should try casting dynamic slot name into constant #4669

Merged
merged 2 commits into from
Aug 9, 2024

Conversation

KermanX
Copy link
Collaborator

@KermanX KermanX commented Aug 8, 2024

fix #4668.

Introduced a new helper:

function __VLS_tryAsConstant<const T>(t: T): T;

which is used to infer the type of an arbitrary expression like as const, but not throwing errors when this can't be done. For example, ("1" + "2") as const will be an error, but __VLS_tryAsConstant("1" + "2") will just be of type string.

btw, I think __VLS_tryAsConstant can be used in other places to provide more precise type info - but it may cause performance issues.

@davidmatter
Copy link
Collaborator

davidmatter commented Aug 8, 2024

You were faster, nice work

@johnsoncodehk
Copy link
Member

Thanks!

@johnsoncodehk johnsoncodehk merged commit c5beb97 into vuejs:master Aug 9, 2024
3 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants