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

When combining the same type, the specific type before combining is still provided #59269

Closed
6 tasks done
xushengfeng opened this issue Jul 14, 2024 · 1 comment
Closed
6 tasks done

Comments

@xushengfeng
Copy link

πŸ” Search Terms

literals, union

βœ… Viability Checklist

⭐ Suggestion

when we use union types, editor can't provide any suggestions.

type a = "a" | "b" | string
// typeof a:string

let v:a
v = "a" // βœ” but without suggestion
v = "other" // βœ”

If we remove string from the union type, we wouldn't be able to set v to any other value.

type a = "a" | "b"
// typeof a:"a"|"b"

let v:a
v = "a" // βœ” with suggestion
v = "other" // ❌

I hope editor can give suggestion about "a"or"b"

πŸ“ƒ Motivating Example

we can give optional value suggestion to user, but user can use other type without error

πŸ’» Use Cases

  1. What do you want to use this for?
    like document.body.style.borderWidth='inherit',editor can give 'inherit'|'thin' and so on, but other string can be set.
  2. What shortcomings exist with current approaches?
    editor can't give more suggestions
  3. What workarounds are you using in the meantime?
    none
@MartinJohns
Copy link
Contributor

Duplicate of #29729. A workaround is to use string & {}.

@xushengfeng xushengfeng closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 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

No branches or pull requests

2 participants