Skip to content

Point the readyWhen type error at the readyWhen value - #1561

Open
Ishkirat-Singh wants to merge 1 commit into
google:mainfrom
Ishkirat-Singh:fix/ready-when-diagnostic-range
Open

Ishkirat-Singh wants to merge 1 commit into
google:mainfrom
Ishkirat-Singh:fix/ready-when-diagnostic-range

Conversation

@Ishkirat-Singh

Copy link
Copy Markdown

When service.readyWhen is not an object, for example "readyWhen": 1, Wireit reports Expected an object., but the diagnostic's range covers the whole "service": {...} object, not the readyWhen value. So the CLI underlines the service block, and in the editor the squiggle spans the whole object, which is an object. That makes the message hard to act on.

In #processService (src/analyzer.ts), the failure for a non-object readyWhen built its location from serviceNode and not from waitForNode (the readyWhen node). The sibling lineMatches checks right below already use their own node. This uses waitForNode for the range.

The existing service.readyWhen must be an object test in src/test/errors-analysis.test.ts had captured the old output. I updated it to expect the error at package.json:9:22, with only the 1 underlined. With the test change but not the fix, the test fails and shows the old range (package.json:8:18, the whole service object underlined). With the fix it passes. I also added an entry under Unreleased > Fixed in CHANGELOG.md.

Testing (Windows, Node 24):

  • tsc --build --pretty, then node --test lib/test/errors-analysis.test.js: 69 tests, 69 pass.
  • prettier --check and eslint pass on the changed files.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant