microsoft / microsoft/vscode-json-languageservice
IntelliSense incorrectly narrows anyOf branches when one variant requires additional properties
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 326
- Forks
- 145
- Avg merge
- 22h 10m
- Merged PRs (30d)
- 9
Description
When authoring against a schema that can branch into a route that requires more properties, or a route that requires no additional properties, VSCode's intellisense has some unexpected behaviour:
Schema:
{
"anyOf": [
{
"type": "object",
"required": [
"type",
"thing"
],
"properties": {
"type": {
"type": "string",
"const": "A"
},
"thing": {
"type": "number"
}
}
},
{
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"const": "B"
}
}
}
]
}
Expected behaviour:
Should show both "A" and "B" as possibilities.
Actual behaviour:
Yet, when hovering over the yellow squiggle, it shows this, which is also not true:
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported schema in VSCode IntelliSense and compare the suggested values and hover warning with the expected A and B branches. No implementation files or tests are named, so trace the JSON language service's anyOf narrowing behavior first; done means both values are offered without an incorrect warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100