Skip to content

Port "Improve unknown narrowing by negated type predicates" #1044

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

Andarist
Copy link
Contributor

@Andarist Andarist commented Jun 4, 2025

@Copilot Copilot AI review requested due to automatic review settings June 4, 2025 14:21
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Ports the enhanced narrowing behavior for unknown when using negated type predicates from upstream TypeScript.

  • Removes the outdated .types.diff baseline file.
  • Updates the expected outputs in narrowUnknownByTypePredicate.types for nullish and non-nullish predicates.
  • Introduces handling of unknownUnionType and wraps filterType results in recombineUnknownType in flow.go.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
testdata/baselines/reference/submodule/compiler/narrowUnknownByTypePredicate.types.diff Removed obsolete baseline diff file
testdata/baselines/reference/submodule/compiler/narrowUnknownByTypePredicate.types Updated expected narrowing outputs for value2 and value4
internal/checker/flow.go Added special unknown handling and recombination logic in flow.go
Comments suppressed due to low confidence (2)

testdata/baselines/reference/submodule/compiler/narrowUnknownByTypePredicate.types.diff:1

  • The baseline diff file was removed; ensure that any test harness configuration or references to this file are also cleaned up to prevent stale entries.
diff --git a/testdata/baselines/reference/submodule/compiler/narrowUnknownByTypePredicate.types.diff b/testdata/baselines/reference/submodule/compiler/narrowUnknownByTypePredicate.types.diff

testdata/baselines/reference/submodule/compiler/narrowUnknownByTypePredicate.types:34

  • Consider adding explicit unit tests or assertions for this updated narrowing behavior to safeguard against regressions in nullish and non-nullish cases.
>value2 : null | undefined

@jakebailey jakebailey changed the title Port Improve unknown narrowing by negated type predicates Port Improve unknown narrowing by negated type predicates Jun 4, 2025
@jakebailey jakebailey changed the title Port Improve unknown narrowing by negated type predicates Port "Improve unknown narrowing by negated type predicates" Jun 4, 2025
@jakebailey jakebailey added this pull request to the merge queue Jun 4, 2025
Merged via the queue into microsoft:main with commit e280a8c Jun 4, 2025
23 checks passed
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.

2 participants