Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Make anyFunctionType a subtype of all function types - #1149
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Introduces anyFunctionType as a wildcard subtype of all other function types, updating signature relation logic and test baselines.
- Adds early-return logic in
signaturesRelatedToto treatanyFunctionTypeas a subtype (but not a supertype) of functions. - Updates test baselines to reflect that callbacks inferred from
useMemonow have parameter typeanyand trigger an implicit-any error. - Adjusts symbol and error snapshots to expect
anyfor parameterx.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/checker/relater.go | Added checks to return TernaryTrue/TernaryFalse for anyFunctionType subtyping |
| testdata/baselines/reference/compiler/subtypeReductionWithAnyFunctionType.types | Updated expected type prints to (x: any) => boolean |
| testdata/baselines/reference/compiler/subtypeReductionWithAnyFunctionType.symbols | Adjusted symbol entries so x is declared with type any |
| testdata/baselines/reference/compiler/subtypeReductionWithAnyFunctionType.errors.txt | Now reports a TS7006 implicit-any error for parameter x |
| } | ||
| if target == r.c.anyFunctionType || r.relation != r.c.strictSubtypeRelation && source == r.c.anyFunctionType { | ||
| // With respect to signatures, the anyFunctionType wildcard is a subtype of every other function type. | ||
| if source == r.c.anyFunctionType { |
There was a problem hiding this comment.
The unconditional TernaryTrue when source is anyFunctionType bypasses signature checks (including return types), which could incorrectly mark incompatible function signatures as subtypes. Consider preserving return-type compatibility or narrowing the early return condition.
Suggested change
| ifsource==r.c.anyFunctionType { | |
| ifsource==r.c.anyFunctionType { | |
| sourceSignatures:=r.c.getSignaturesOfType(source, kind) | |
| targetSignatures:=r.c.getSignaturesOfType(target, kind) | |
| for_, s:=rangesourceSignatures { | |
| for_, t:=rangetargetSignatures { | |
| ifr.signatureRelatedTo(s, t, true/*erase*/, reportErrors, intersectionState) ==TernaryFalse { | |
| returnTernaryFalse | |
| } | |
| } | |
| } |
Jake Bailey (jakebailey)
approved these changes
Jun 10, 2025
github-merge-queueBot
removed this pull request from the merge queue due to failed status checks
Jun 10, 2025
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Feb 12, 2026
Jake Bailey (jakebailey) pushed a commit
to jakebailey/TypeScript
that referenced
this pull request
Aug 13, 2026
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 freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Implements what I discuss here.
Fixes#1016.