Port #61683: Use getNonMissingTypeOfSymbol in compareProperties#2726
Port #61683: Use getNonMissingTypeOfSymbol in compareProperties#2726jakebailey merged 3 commits intomainfrom
Conversation
…operties Don't compare "missing" to undefined in compareProperties under exactOptionalPropertyTypes. This changes getTypeOfSymbol to getNonMissingTypeOfSymbol for both source and target properties in the compareProperties function. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR ports microsoft/TypeScript#61683 to fix a bug in property comparison under exactOptionalPropertyTypes mode. The issue caused optional properties with and without explicit | undefined to be incorrectly treated as identical in conditional type resolution.
Changes:
- Updated
comparePropertiesto usegetNonMissingTypeOfSymbolinstead ofgetTypeOfSymbolto properly strip the internal "missing" type marker before comparison - Added test baseline showing the now-correctly-detected type error for the scenario described in the issue
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/checker/checker.go | Changed property type comparison to use getNonMissingTypeOfSymbol for both source and target properties |
| testdata/baselines/reference/submodule/compiler/exactOptionalPropertyTypesIdentical.errors.txt | Added expected error output showing the fix correctly detects type incompatibility |
| testdata/baselines/reference/submodule/compiler/exactOptionalPropertyTypesIdentical.errors.txt.diff | Removed the diff file indicating no previous errors were expected |
|
@copilot You still need to run the tests and accept all baseline changes |
Accept baseline for multipleBaseInterfaesWithIncompatibleProperties2 with exactoptionalpropertytypes=true, which now correctly reports TS2320 error matching the TypeScript reference. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Ran the full test suite and accepted all baseline changes in |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
getTypeOfSymboltogetNonMissingTypeOfSymbolincomparePropertiesfunction (checker.go:27072)💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.