-
Notifications
You must be signed in to change notification settings - Fork 640
Improve type discrimination algorithm #1085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the type discrimination algorithm in the checker, adds new tests for missing discriminants, and updates baselines for error outputs.
- Added
missingDiscriminants.ts
tests to cover cases where discriminants are partially missing. - Updated reference baselines under
submodule/compiler
andcompiler
to reflect the revised discrimination behavior. - Modified
relater.go
to change howTernaryMaybe
is applied within the discrimination loop.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
testdata/tests/cases/compiler/missingDiscriminants.ts | New test cases for missing discriminants behavior |
testdata/baselines/reference/submodule/compiler/discriminateWithMissingProperty.errors.txt.diff | Cleared outdated submodule error baseline |
testdata/baselines/reference/submodule/compiler/discriminateWithMissingProperty.errors.txt | Removed old submodule error baseline content |
testdata/baselines/reference/compiler/missingDiscriminants.types | New type-check baseline for missing discriminants tests |
testdata/baselines/reference/compiler/missingDiscriminants.symbols | New symbol baseline for missing discriminants tests |
testdata/baselines/reference/compiler/missingDiscriminants.errors.txt | New error baseline for missing discriminants tests |
internal/checker/relater.go | Adjusted discrimination logic to separate property-check and match |
Comments suppressed due to low confidence (1)
internal/checker/relater.go:1228
- The inserted closing brace here appears to end the
for
loop prematurely, changing the intended nesting and control flow. Remove or reposition it so that the loop and subsequent logic maintain their original scopes.
}
testdata/baselines/reference/submodule/compiler/discriminateWithMissingProperty.errors.txt
Show resolved
Hide resolved
Ported it over in microsoft/TypeScript#61828 and it fails the self test. I wonder why this doesn't fail in CI here. |
Ah, because the failure isn't in src/compiler, which is what we test here given we don't have build mode. |
The man, the myth, the legend 🫡 |
Implements what I suggest here.
We might consider back-porting this to the old code base.
Fixes #1020.