feat: output the type of object properties in error messages - #224
Merged
alexander-akait merged 1 commit intoSep 8, 2026
Merged
Conversation
An error listing the shape of an object gave the property names only, so a
message told which properties are valid but not what they take:
configuration.v should be an object:
object { foo?, bar? }
The type is now named next to the property:
configuration.v should be an object:
object { foo?: boolean, bar?: integer }
A type is only named when it is a short leaf one. A union, an object or an
array is left out, listing it inline buries the property names it sits with,
and the constraints a type carries are dropped, the error on the property
itself states them anyway. The types are dropped entirely once the shape no
longer fits in a line, an object with that many properties is hard enough to
read by the names alone - webpack's own schema renders byte for byte as
before apart from one nested three-property object.
Closes #42
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #224 +/- ##
==========================================
+ Coverage 95.96% 96.66% +0.69%
==========================================
Files 9 9
Lines 967 989 +22
Branches 393 408 +15
==========================================
+ Hits 928 956 +28
+ Misses 35 31 -4
+ Partials 4 2 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alexander-akait
deleted the
claude/filter-errors-quadratic-sibling-dos-1tqe2l
branch
September 8, 2026 15:28
This was referenced Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #42.
The issue asks for two things.
1. The
notkeywordAlready fixed on
main, so this only locks the issue's three examples into snapshots:not: { minimum: 3 }should be any non-number | number (should be < 3).not: { type: "string" }should be any non-string.not: { enum: [1, 2] }should not be 1 | 2.2. The type of each property
An error listing the shape of an object gave the property names only, so it said which properties are valid but not what they take:
The type is now named next to the property, the form asked for in #42:
The existing comment on that code (
Maybe we should output type of property (foo: string), but it is looks very unreadable) is the real difficulty here, and it is right — naming every type unconditionally takes the longest line webpack's own schema produces from 1360 to 1959 characters. Three rules keep the output readable:number (should be >= 2)is namednumber— the error on the property itself states the constraint anyway.Effect on webpack
Validated against webpack's own
schemas/WebpackOptions.jsonover a spread of invalid configurations. Exactly one line of the resulting messages changes, and it gets better:Total output goes from 11024 to 11041 characters and the longest line is unchanged at 1360 — the big objects (
stats,resolve,entry) render byte for byte as before.Tests
Four cases in
test/api.test.jscovering the issue's example, composite types being left out, the width cap, and the threenotexamples. 22 existing snapshots move, each towards more information on a line no longer than before, e.g.object { apply: function, … }andobject { foo?: string, bar?: number }.npm test(490 tests, 338 snapshots),npm run lintandnpm run buildall pass.🤖 Generated with Claude Code
https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
Generated by Claude Code