Skip to content

Intellisense suggests invalid property values within union objects #53165

Closed
@Xenomer

Description

@Xenomer

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.76.0
  • OS Version: Windows 11 22H2 (22621.1265)

Steps to Reproduce:

  1. Using the following object union type:
type TestType = {
  key1: 'a',
  key2: '1',
} | {
  key1: 'a',
  key2: '2',
} | {
  key1: 'b',
  key2: '3',
}
  1. Even though key2: '1' | '2' when key1 is 'a', VSCode suggest 1, 2 and 3 as b values:
    image
    The underlying type checker even knows the correct values for key2, and throws a problem if theyre used: (note the key2: "1" | "2" part)
    image

This causes bigger usability problems when used with larger unions and objects where VSCode spills the suggestions with lots of incorrect ones.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions