Add lint rule for identifying common patterns in the checker that lead to inconsistent diagnostic output#4708
Open
weswigham wants to merge 5 commits into
Open
Conversation
jakebailey
reviewed
Jul 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds diagnostic-stability enforcement for checker traversal and resolves inherited TS-1 baseline inconsistencies.
Changes:
- Adds the
checkchildrencustom lint analyzer and tests. - Checks child nodes before checker error-path returns.
- Fails tests on TS-1 diagnostics and updates affected baselines.
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
testdata/tests/cases/compiler/checkChildrenAlwaysChecked.ts |
Adds checker regression cases. |
testdata/submoduleAccepted.txt |
Documents accepted diagnostic differences. |
testdata/baselines/reference/submoduleAccepted/conformance/YieldExpression2_es6.errors.txt.diff |
Updates yield diagnostics. |
testdata/baselines/reference/submoduleAccepted/conformance/YieldExpression17_es6.errors.txt.diff |
Updates yield diagnostics. |
testdata/baselines/reference/submoduleAccepted/conformance/YieldExpression15_es6.errors.txt.diff |
Updates yield diagnostics. |
testdata/baselines/reference/submoduleAccepted/conformance/YieldExpression14_es6.errors.txt.diff |
Updates yield diagnostics. |
testdata/baselines/reference/submoduleAccepted/conformance/YieldExpression12_es6.errors.txt.diff |
Updates yield diagnostics. |
testdata/baselines/reference/submoduleAccepted/conformance/parserStatementIsNotAMemberVariableDeclaration1(alwaysstrict=true).errors.txt.diff |
Removes TS-1 instability. |
testdata/baselines/reference/submoduleAccepted/conformance/parserExportAssignment9.errors.txt.diff |
Updates export diagnostics. |
testdata/baselines/reference/submoduleAccepted/conformance/parserExportAssignment5.errors.txt.diff |
Updates export diagnostics. |
testdata/baselines/reference/submoduleAccepted/conformance/parserErrorRecovery_ModuleElement1.errors.txt.diff |
Updates recovery diagnostics. |
testdata/baselines/reference/submoduleAccepted/conformance/jsdocDisallowedInTypescript.errors.txt.diff |
Updates malformed-code diagnostics. |
testdata/baselines/reference/submoduleAccepted/compiler/reachabilityChecksNoCrash1.errors.txt.diff |
Updates recovery diagnostics. |
testdata/baselines/reference/submoduleAccepted/compiler/parseErrorIncorrectReturnToken.errors.txt.diff |
Removes TS-1 instability. |
testdata/baselines/reference/submoduleAccepted/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt.diff |
Removes TS-1 instability. |
testdata/baselines/reference/submoduleAccepted/compiler/constructorWithIncompleteTypeAnnotation.errors.txt.diff |
Removes TS-1 instability. |
testdata/baselines/reference/submodule/conformance/YieldExpression2_es6.errors.txt |
Records yield operand errors. |
testdata/baselines/reference/submodule/conformance/YieldExpression17_es6.errors.txt |
Records yield operand errors. |
testdata/baselines/reference/submodule/conformance/YieldExpression15_es6.errors.txt |
Records yield operand errors. |
testdata/baselines/reference/submodule/conformance/YieldExpression14_es6.errors.txt |
Records yield operand errors. |
testdata/baselines/reference/submodule/conformance/YieldExpression12_es6.errors.txt |
Records yield operand errors. |
testdata/baselines/reference/submodule/conformance/parserStatementIsNotAMemberVariableDeclaration1(alwaysstrict=true).errors.txt |
Stabilizes return diagnostics. |
testdata/baselines/reference/submodule/conformance/parserExportAssignment9.errors.txt |
Records export operand errors. |
testdata/baselines/reference/submodule/conformance/parserExportAssignment5.errors.txt |
Records export operand errors. |
testdata/baselines/reference/submodule/conformance/parserErrorRecovery_ModuleElement1.errors.txt |
Records recovered return errors. |
testdata/baselines/reference/submodule/conformance/jsdocDisallowedInTypescript.errors.txt |
Records additional semantic errors. |
testdata/baselines/reference/submodule/compiler/reachabilityChecksNoCrash1.errors.txt |
Records additional name error. |
testdata/baselines/reference/submodule/compiler/parseErrorIncorrectReturnToken.errors.txt |
Stabilizes recovered return diagnostics. |
testdata/baselines/reference/submodule/compiler/multiLinePropertyAccessAndArrowFunctionIndent1.errors.txt |
Stabilizes return-expression diagnostics. |
testdata/baselines/reference/submodule/compiler/constructorWithIncompleteTypeAnnotation.errors.txt |
Stabilizes malformed-constructor diagnostics. |
testdata/baselines/reference/compiler/checkChildrenAlwaysChecked.types |
Adds type baseline. |
testdata/baselines/reference/compiler/checkChildrenAlwaysChecked.symbols |
Adds symbol baseline. |
testdata/baselines/reference/compiler/checkChildrenAlwaysChecked.errors.txt |
Adds diagnostic baseline. |
internal/testutil/tsbaseline/error_baseline.go |
Fails tests containing TS-1 diagnostics. |
internal/checker/utilities.go |
Identifies special resolution contexts. |
internal/checker/checker.go |
Ensures child checking across error paths. |
_tools/customlint/testdata/checkchildren/checkchildren.go.golden |
Defines analyzer expectations. |
_tools/customlint/testdata/checkchildren/checkchildren.go |
Adds analyzer test cases. |
_tools/customlint/plugin.go |
Registers the analyzer. |
_tools/customlint/checkchildren.go |
Implements early-return analysis. |
jakebailey
reviewed
Jul 23, 2026
Comment on lines
+222
to
+223
| for cur := ret; ; { | ||
| parent := cur.Parent() |
Member
There was a problem hiding this comment.
Not just cur := ret then for {}?
jakebailey
reviewed
Jul 23, 2026
| // statements that genuinely follow `ret` in execution order are considered: | ||
| // mutually exclusive branches (the other arm of an if, sibling switch cases) are | ||
| // not, while loop bodies are revisited in full. | ||
| func reachableChecksAfter(ret inspector.Cursor, checks []inspector.Cursor) []inspector.Cursor { |
Member
There was a problem hiding this comment.
at some level I wonder if you could just reuse some of the shadow code for this, but that's probably a pain
Member
|
@typescript-bot test it |
|
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
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.
And fix the issues it flags, fixing the
TS-1diagnostic consistency issues we inherited from strada, and also allowing some simplification of the fixes I'd already made for new ones tomarkLinkedReferences.This removes the remaining
TS-1consistency issues we inherited from strada in:Generally, the approach taken to fix them is an anti-brittle one - we no longer skip actually checking the children in the affected cases (
yield,return,export =) when a grammar error is present, allowing us to always report the same diagnostic regardless of if checking starts inside the node with a grammar error or outside it. In some cases (likeexport =), this meant pushing some logic for the error into the child (eg,resolveNamenow knows not to report errors onas constorexport = typeNamesince those either... aren't errors, or, in cases where they are, something other-than-resolveName will report them).All up, that removes the last errors in our tests, allowing me to add the test failure I described in #4527 and finally say:
Fixes #4527