Skip to content

Port anyFunctionType subtype fix and JSX children NonInferrableType propagation from typescript-go#63163

Open
Copilot wants to merge 2 commits intomainfrom
copilot/port-function-type-subtype
Open

Port anyFunctionType subtype fix and JSX children NonInferrableType propagation from typescript-go#63163
Copilot wants to merge 2 commits intomainfrom
copilot/port-function-type-subtype

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Ports two fixes from typescript-go:

anyFunctionType subtype relation

In signaturesRelatedTo, anyFunctionType was treated symmetrically—both as source and target it returned Ternary.True. This caused incorrect subtype reduction: when a union included anyFunctionType alongside a real function type, the real type could be reduced away instead of the wildcard.

Now anyFunctionType is a proper subtype (source → True) but not a supertype (target → False). This fixes inference in patterns like:

declare function useMemo<T>(func: () => T): T;

const predicate = useMemo(() => {
    if (cond) return () => true;    // anyFunctionType
    return x => x.length > 0;      // previously inferred x: string, now correctly x: any + TS7006
});

JSX children NonInferrableType propagation

When building the JSX attributes spread type for children, getPropagatingFlagsOfTypes(childrenTypes) was not included in the objectFlags passed to getSpreadType. This meant the NonInferrableType flag from anyFunctionType children wasn't propagated, breaking context-sensitive discrimination for generic JSX component signatures.

// children as JSX body now correctly infers `selected: number`
<TestComponent state={{ foo: 123 }} selector={(state) => state.foo}>
  {(selected) => <div>{Math.max(selected, 0)}</div>}
</TestComponent>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@typescript-bot typescript-bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Feb 19, 2026
…NonInferrableType propagation

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Port changes from multiple PRs on function types and JSX Port anyFunctionType subtype fix and JSX children NonInferrableType propagation from typescript-go Feb 19, 2026
@DanielRosenwasser
Copy link
Member

@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 19, 2026

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ❌ Results
perf test this faster ✅ Started 👀 Results

Copy link
Contributor

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 two TypeScript type-checker fixes from typescript-go into the main compiler: (1) correct subtype reduction behavior involving the internal anyFunctionType wildcard, and (2) ensure JSX children spread types propagate NonInferrableType so context-sensitive discrimination works for generic JSX component signatures.

Changes:

  • Update signature relatedness so anyFunctionType is treated as a subtype (source) but not as a supertype (target) of other function types.
  • Propagate getPropagatingFlagsOfTypes(childrenTypes) into the object flags passed to getSpreadType when synthesizing JSX children.
  • Add new compiler regression tests and reference baselines covering the subtype reduction and JSX children inference scenarios.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/compiler/checker.ts Adjusts anyFunctionType signature relatedness semantics; propagates children flags (incl. NonInferrableType) into JSX children spread typing.
tests/cases/compiler/subtypeReductionWithAnyFunctionType.ts New regression test for union subtype reduction involving anyFunctionType, ensuring real function types aren’t incorrectly reduced away.
tests/baselines/reference/subtypeReductionWithAnyFunctionType.types Type baseline validating inferred types (notably the any parameter) for the new subtype reduction test.
tests/baselines/reference/subtypeReductionWithAnyFunctionType.symbols Symbols baseline for the new subtype reduction test.
tests/baselines/reference/subtypeReductionWithAnyFunctionType.errors.txt Error baseline asserting the expected TS7006 implicit-any diagnostic.
tests/cases/compiler/jsxFunctionTypeChildren.tsx New regression test ensuring JSX children function typing behaves like the equivalent non-JSX call in a generic props scenario.
tests/baselines/reference/jsxFunctionTypeChildren.types Type baseline for the JSX children function typing test.
tests/baselines/reference/jsxFunctionTypeChildren.symbols Symbols baseline for the JSX children function typing test.
tests/cases/compiler/contextuallyTypedJsxChildren2.tsx New regression test for context-sensitive JSX children discrimination with generic signatures (children-body vs non-children prop).
tests/baselines/reference/contextuallyTypedJsxChildren2.types Type baseline validating correct inference (e.g. selected: number) for the JSX discrimination test.
tests/baselines/reference/contextuallyTypedJsxChildren2.symbols Symbols baseline for the JSX discrimination test.

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, it looks like the DT test run failed. Please check the log for more details.

You can check the log here.

@jakebailey
Copy link
Member

@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 20, 2026

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
run dt ✅ Started ❌ Results

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser Here are the results of running the user tests with tsc comparing main and refs/pull/63163/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, it looks like the DT test run failed. Please check the log for more details.

You can check the log here.

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 82,521 82,521 ~ ~ ~ p=1.000 n=6
Types 125,280 125,280 ~ ~ ~ p=1.000 n=6
Memory used 275,082k (± 0.50%) 276,155k (± 0.67%) ~ 274,428k 277,929k p=0.471 n=6
Parse Time 1.30s (± 0.42%) 1.30s (± 0.63%) ~ 1.29s 1.31s p=0.859 n=6
Bind Time 0.76s (± 0.68%) 0.75s (± 0.68%) ~ 0.75s 0.76s p=0.311 n=6
Check Time 14.16s (± 0.41%) 14.15s (± 0.50%) ~ 14.04s 14.25s p=1.000 n=6
Emit Time 2.67s (± 0.39%) 2.66s (± 0.61%) ~ 2.64s 2.68s p=1.000 n=6
Total Time 18.88s (± 0.31%) 18.87s (± 0.36%) ~ 18.77s 18.97s p=1.000 n=6
angular-1 - node (v18.15.0, x64)
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 959,126 959,126 ~ ~ ~ p=1.000 n=6
Types 416,034 416,034 ~ ~ ~ p=1.000 n=6
Memory used 1,260,822k (± 0.00%) 1,260,855k (± 0.00%) ~ 1,260,780k 1,260,915k p=0.298 n=6
Parse Time 6.51s (± 0.48%) 6.55s (± 0.63%) ~ 6.50s 6.62s p=0.221 n=6
Bind Time 1.97s (± 0.38%) 1.97s (± 0.21%) ~ 1.97s 1.98s p=0.389 n=6
Check Time 32.45s (± 0.28%) 32.34s (± 0.29%) ~ 32.19s 32.48s p=0.065 n=6
Emit Time 15.09s (± 0.35%) 15.07s (± 0.36%) ~ 15.01s 15.17s p=0.518 n=6
Total Time 56.02s (± 0.25%) 55.92s (± 0.17%) ~ 55.83s 56.04s p=0.378 n=6
mui-docs - node (v18.15.0, x64)
Errors 11,439 11,439 ~ ~ ~ p=1.000 n=6
Symbols 2,706,620 2,706,879 +259 (+ 0.01%) ~ ~ p=0.001 n=6
Types 931,168 931,241 +73 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 3,046,078k (± 0.00%) 3,046,217k (± 0.01%) ~ 3,046,108k 3,046,500k p=0.066 n=6
Parse Time 8.53s (± 0.29%) 8.53s (± 0.35%) ~ 8.47s 8.55s p=0.685 n=6
Bind Time 2.31s (± 0.42%) 2.32s (± 0.18%) ~ 2.32s 2.33s p=0.056 n=6
Check Time 95.50s (± 0.60%) 95.42s (± 0.39%) ~ 95.10s 95.93s p=0.873 n=6
Emit Time 0.32s (± 1.97%) 0.32s (± 2.34%) ~ 0.31s 0.33s p=0.718 n=6
Total Time 106.66s (± 0.53%) 106.59s (± 0.33%) ~ 106.28s 107.05s p=0.936 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,253,407 1,253,407 ~ ~ ~ p=1.000 n=6
Types 260,208 260,208 ~ ~ ~ p=1.000 n=6
Memory used 2,396,837k (± 0.04%) 2,518,404k (±11.85%) ~ 2,395,920k 3,128,223k p=0.810 n=6
Parse Time 5.19s (± 1.45%) 5.18s (± 1.41%) ~ 5.11s 5.29s p=1.000 n=6
Bind Time 1.87s (± 0.55%) 1.84s (± 1.27%) -0.03s (- 1.61%) 1.81s 1.87s p=0.041 n=6
Check Time 35.69s (± 0.28%) 35.69s (± 0.48%) ~ 35.50s 35.98s p=0.936 n=6
Emit Time 2.99s (± 1.21%) 3.02s (± 2.75%) ~ 2.92s 3.13s p=0.471 n=6
Total Time 45.77s (± 0.36%) 45.76s (± 0.41%) ~ 45.49s 46.02s p=0.873 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,253,407 1,253,407 ~ ~ ~ p=1.000 n=6
Types 260,208 260,208 ~ ~ ~ p=1.000 n=6
Memory used 3,073,635k (± 9.65%) 3,072,946k (± 9.66%) ~ 2,466,271k 3,194,475k p=0.471 n=6
Parse Time 8.44s (± 1.65%) 8.43s (± 1.43%) ~ 8.23s 8.58s p=0.936 n=6
Bind Time 2.74s (± 1.68%) 2.77s (± 1.27%) ~ 2.73s 2.83s p=0.108 n=6
Check Time 53.56s (± 0.46%) 53.37s (± 0.17%) ~ 53.28s 53.53s p=0.093 n=6
Emit Time 4.36s (± 1.51%) 4.33s (± 2.01%) ~ 4.23s 4.42s p=0.810 n=6
Total Time 69.11s (± 0.53%) 68.91s (± 0.32%) ~ 68.58s 69.12s p=0.297 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 265,173 265,173 ~ ~ ~ p=1.000 n=6
Types 104,282 104,282 ~ ~ ~ p=1.000 n=6
Memory used 444,507k (± 0.02%) 444,537k (± 0.01%) ~ 444,466k 444,624k p=0.936 n=6
Parse Time 3.52s (± 1.40%) 3.52s (± 0.83%) ~ 3.48s 3.57s p=1.000 n=6
Bind Time 1.38s (± 0.79%) 1.37s (± 1.41%) ~ 1.36s 1.41s p=0.187 n=6
Check Time 19.29s (± 0.35%) 19.28s (± 0.38%) ~ 19.21s 19.41s p=0.810 n=6
Emit Time 1.54s (± 0.68%) 1.55s (± 1.29%) ~ 1.53s 1.58s p=1.000 n=6
Total Time 25.73s (± 0.44%) 25.73s (± 0.22%) ~ 25.67s 25.82s p=0.810 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 271 271 ~ ~ ~ p=1.000 n=6
Symbols 225,883 225,883 ~ ~ ~ p=1.000 n=6
Types 93,564 93,564 ~ ~ ~ p=1.000 n=6
Memory used 371,591k (± 0.02%) 371,612k (± 0.01%) ~ 371,568k 371,647k p=0.230 n=6
Parse Time 2.86s (± 0.57%) 2.83s (± 1.38%) ~ 2.76s 2.87s p=0.089 n=6
Bind Time 1.63s (± 1.58%) 1.63s (± 1.38%) ~ 1.59s 1.66s p=0.803 n=6
Check Time 17.46s (± 0.35%) 17.46s (± 0.41%) ~ 17.38s 17.57s p=0.936 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 21.96s (± 0.18%) 21.92s (± 0.37%) ~ 21.81s 22.04s p=0.332 n=6
vscode - node (v18.15.0, x64)
Errors 57 57 ~ ~ ~ p=1.000 n=5+6
Symbols 4,359,723 4,359,721 -2 (- 0.00%) ~ ~ p=0.002 n=5+6
Types 1,386,348 1,386,348 ~ ~ ~ p=1.000 n=5+6
Memory used 4,162,029k (± 0.01%) 4,162,113k (± 0.00%) ~ 4,161,912k 4,162,318k p=0.411 n=5+6
Parse Time 16.67s (± 0.70%) 16.66s (± 0.75%) ~ 16.54s 16.86s p=0.855 n=5+6
Bind Time 5.67s (± 1.15%) 5.64s (± 0.29%) ~ 5.62s 5.66s p=0.167 n=5+6
Check Time 138.15s (± 2.79%) 142.66s (± 3.94%) ~ 134.85s 148.92s p=0.235 n=5+6
Emit Time 88.34s (± 4.34%) 88.31s (± 4.40%) ~ 84.49s 92.23s p=0.784 n=5+6
Total Time 248.82s (± 1.90%) 253.28s (± 1.42%) ~ 249.58s 258.99s p=0.055 n=5+6
webpack - node (v18.15.0, x64)
Errors 41 41 ~ ~ ~ p=1.000 n=6
Symbols 407,330 407,330 ~ ~ ~ p=1.000 n=6
Types 186,189 186,189 ~ ~ ~ p=1.000 n=6
Memory used 568,814k (± 0.01%) 568,750k (± 0.01%) ~ 568,667k 568,794k p=0.128 n=6
Parse Time 4.81s (± 0.61%) 4.78s (± 0.45%) ~ 4.75s 4.81s p=0.124 n=6
Bind Time 2.04s (± 1.79%) 2.04s (± 1.05%) ~ 2.01s 2.06s p=1.000 n=6
Check Time 24.66s (± 0.26%) 24.47s (± 0.60%) -0.20s (- 0.79%) 24.22s 24.63s p=0.013 n=6
Emit Time 0.00s (±154.76%) 0.00s (±154.76%) ~ 0.00s 0.01s p=1.000 n=6
Total Time 31.52s (± 0.26%) 31.30s (± 0.50%) -0.22s (- 0.70%) 31.03s 31.47s p=0.013 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 764,198 764,198 ~ ~ ~ p=1.000 n=6
Types 219,050 219,050 ~ ~ ~ p=1.000 n=6
Memory used 684,903k (± 0.01%) 684,850k (± 0.01%) ~ 684,762k 684,948k p=0.173 n=6
Parse Time 4.89s (± 0.83%) 4.92s (± 0.73%) ~ 4.87s 4.97s p=0.146 n=6
Bind Time 1.57s (± 0.48%) 1.59s (± 1.05%) ~ 1.57s 1.61s p=0.080 n=6
Check Time 22.56s (± 0.52%) 22.60s (± 0.53%) ~ 22.47s 22.75s p=0.748 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 29.02s (± 0.42%) 29.11s (± 0.39%) ~ 28.99s 29.30s p=0.261 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser Here are the results of running the top 400 repos with tsc comparing main and refs/pull/63163/merge:

Everything looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments