Skip to content

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

Closed as not planned
@xushengfeng

Description

@xushengfeng

πŸ” 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions