Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Port "Narrow types by satisfies expressions" #1047

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:50
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 TypeScript change “Narrow types by satisfies expressions” to downstream flow analysis and updates related test baselines.

  • Updated several test baselines to reflect new narrowing behavior when a predicate uses satisfies.
  • Adjusted declaration and JS baselines for isEmptyString to restore its type‐predicate signature.
  • Enhanced flow.go to recognize SatisfiesExpression in type narrowing and reference matching.

Reviewed Changes

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

Show a summary per file
File Description
testdata/baselines/reference/submodule/compiler/inferTypePredicates.types.diff Updated expected outputs for .filter(... satisfies boolean) and isEmptyString.
testdata/baselines/reference/submodule/compiler/inferTypePredicates.types Refined type annotations for filter result and predicate signature.
testdata/baselines/reference/submodule/compiler/inferTypePredicates.js.diff Cleaned up intermediate boolean signature change for isEmptyString.
testdata/baselines/reference/submodule/compiler/inferTypePredicates.js Restored isEmptyString as a type predicate (x is "").
testdata/baselines/reference/submodule/compiler/inferTypePredicates.errors.txt.diff Removed stale error entries related to filter narrowing.
testdata/baselines/reference/submodule/compiler/inferTypePredicates.errors.txt Updated error count and removed obsolete errors for satisfies.
internal/checker/flow.go Added ast.KindSatisfiesExpression to narrowType and reference matching.
Comments suppressed due to low confidence (1)

testdata/baselines/reference/submodule/compiler/inferTypePredicates.types:1018

  • There aren’t explicit unit tests covering nested satisfies expressions for narrowing; consider adding test cases to validate both direct and nested uses of satisfies in predicates.
->[1, 2, null, 3].filter(  (x) => (x != null) satisfies boolean,) : number[]

@jakebailey jakebailey added this pull request to the merge queue Jun 4, 2025
Merged via the queue into microsoft:main with commit 3f44634 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