microsoft / microsoft/TypeScript

Shorten error spans for missing key errors reported on object literals

Open
#58,062 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Proposal Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔍 Search Terms

object literal, error span, squigglies, highlight, decoration, editor, range

✅ Viability Checklist
⭐ Suggestion

When defining an object literal with a missing key, e.g. as a function input, highlight only the first line of the object literal as opposed to the entire node.

📃 Motivating Example

Current behavior (one parameter with missing key):

image

Suggested behavior (one parameter with missing key):
image

Current behavior (two parameters with missing keys):
image

Suggested behavior(two parameters with missing keys):
image

Here's a TS playground link with the original source:

https://tsplay.dev/N9a3qN

💻 Use Cases

This would make errors clearer and less jarring when defining large objects as function inputs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked TS Playground example and reproduce the missing-key diagnostics for one and two object-literal parameters. Trace where the diagnostic range is selected for these errors, then verify that each highlight stops at the first line of the object literal rather than covering the entire node.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.