Skip to content

Avoid silentNeverType leaking into generator types inferred based on inner generic calls at yields #62283

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

This is an improvement over one of the recent PRs: #61317

@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 17:38
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Aug 13, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 13, 2025
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

1 similar comment
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copy link

@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

This PR fixes an issue where silentNeverType was incorrectly leaking into generator types when inferring types based on inner generic calls at yield expressions. The change improves type inference for generators that use yield* with generic function calls by preventing premature type narrowing to never.

Key changes:

  • Removes special handling of silentNeverType in yield expression type checking
  • Modifies check mode for yield expressions to skip generic function checks
  • Updates test baselines to reflect improved type inference from never to any

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/compiler/checker.ts Core fix removing silentNeverType handling and adjusting check modes
tests/cases/compiler/genericCallAtYieldExpressionInGenericCall1.ts Additional test cases for the fix
tests/baselines/reference/*.types Updated type baselines showing improved inference
tests/baselines/reference/*.errors.txt New error baselines for test cases
tests/baselines/reference/*.symbols Symbol baselines for new test cases

@@ -39208,7 +39207,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const nextTypes: Type[] = [];
const isAsync = (getFunctionFlags(func) & FunctionFlags.Async) !== 0;
forEachYieldExpression(func.body as Block, yieldExpression => {
const yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
const yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode && checkMode & ~CheckMode.SkipGenericFunctions) : undefinedWideningType;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is exactly what the cousin (checkAndAggregateReturnExpressionTypes) of this function (checkAndAggregateYieldOperandTypes) does

@@ -47,8 +47,8 @@ outer(function* <T>(value: T) {
> : ^^^^
>outer : <A>(body: (value: A) => Generator<any, any, any>) => void
> : ^ ^^ ^^ ^^^^^
>function* <T>(value: T) { const result = yield* inner(value); // ok} : <T>(value: T) => Generator<never, void, never>
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>function* <T>(value: T) { const result = yield* inner(value); // ok} : <T>(value: T) => Generator<any, void, any>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the new results here are better and match the other results that have inner~ function called beforehand (when its precomputed result is yield*ed)

@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 13, 2025

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

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/62283/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

@jakebailey
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 34 34 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,386 50,386 ~ ~ ~ p=1.000 n=6
Memory used 194,191k (± 0.93%) 193,535k (± 0.76%) ~ 192,925k 196,547k p=0.810 n=6
Parse Time 1.31s (± 0.62%) 1.30s (± 0.84%) ~ 1.29s 1.31s p=0.282 n=6
Bind Time 0.73s (± 0.56%) 0.73s ~ ~ ~ p=0.405 n=6
Check Time 9.76s (± 0.50%) 9.75s (± 0.17%) ~ 9.73s 9.77s p=0.806 n=6
Emit Time 2.73s (± 0.60%) 2.74s (± 0.76%) ~ 2.72s 2.77s p=0.742 n=6
Total Time 14.52s (± 0.34%) 14.52s (± 0.20%) ~ 14.49s 14.57s p=0.872 n=6
angular-1 - node (v18.15.0, x64)
Errors 56 56 ~ ~ ~ p=1.000 n=6
Symbols 948,914 948,914 ~ ~ ~ p=1.000 n=6
Types 410,884 410,884 ~ ~ ~ p=1.000 n=6
Memory used 1,226,382k (± 0.01%) 1,226,390k (± 0.01%) ~ 1,226,310k 1,226,490k p=0.810 n=6
Parse Time 6.53s (± 0.89%) 6.53s (± 0.83%) ~ 6.47s 6.59s p=1.000 n=6
Bind Time 1.88s (± 0.43%) 1.87s (± 0.44%) ~ 1.86s 1.88s p=0.666 n=6
Check Time 32.06s (± 0.50%) 32.01s (± 0.27%) ~ 31.90s 32.12s p=0.688 n=6
Emit Time 14.74s (± 1.08%) 14.81s (± 0.39%) ~ 14.72s 14.89s p=0.810 n=6
Total Time 55.22s (± 0.49%) 55.22s (± 0.13%) ~ 55.13s 55.33s p=0.936 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,545,695 2,545,695 ~ ~ ~ p=1.000 n=6
Types 902,474 902,474 ~ ~ ~ p=1.000 n=6
Memory used 2,830,902k (± 0.09%) 2,829,935k (± 0.01%) ~ 2,829,645k 2,830,083k p=0.936 n=6
Parse Time 8.75s (± 0.22%) 8.73s (± 0.36%) ~ 8.70s 8.77s p=0.413 n=6
Bind Time 2.24s (± 0.63%) 2.24s (± 0.92%) ~ 2.20s 2.26s p=1.000 n=6
Check Time 85.97s (± 0.48%) 86.35s (± 0.65%) ~ 85.81s 87.35s p=0.298 n=6
Emit Time 0.71s (±95.51%) 0.66s (±116.27%) ~ 0.30s 2.21s p=0.932 n=6
Total Time 97.67s (± 0.96%) 97.99s (± 0.76%) ~ 97.12s 98.99s p=0.689 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,066 1,227,065 -1 (- 0.00%) ~ ~ p=0.001 n=6
Types 267,480 267,480 ~ ~ ~ p=1.000 n=6
Memory used 2,975,665k (±10.03%) 2,854,116k (±13.23%) ~ 2,365,761k 3,098,663k p=0.810 n=6
Parse Time 6.71s (± 1.18%) 6.70s (± 1.57%) ~ 6.57s 6.82s p=1.000 n=6
Bind Time 2.15s (± 1.52%) 2.19s (± 1.57%) ~ 2.14s 2.23s p=0.064 n=6
Check Time 43.03s (± 0.13%) 43.01s (± 0.65%) ~ 42.53s 43.26s p=1.000 n=6
Emit Time 3.53s (± 1.27%) 3.46s (± 3.36%) ~ 3.30s 3.65s p=0.229 n=6
Total Time 55.42s (± 0.23%) 55.37s (± 0.55%) ~ 54.81s 55.67s p=0.936 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,066 1,227,065 -1 (- 0.00%) ~ ~ p=0.001 n=6
Types 267,480 267,480 ~ ~ ~ p=1.000 n=6
Memory used 3,040,424k (± 9.78%) 3,067,139k (± 7.60%) ~ 2,590,627k 3,162,871k p=0.230 n=6
Parse Time 8.56s (± 1.84%) 8.53s (± 0.82%) ~ 8.40s 8.58s p=0.470 n=6
Bind Time 2.65s (± 1.78%) 2.69s (± 1.38%) ~ 2.65s 2.73s p=0.128 n=6
Check Time 53.30s (± 0.25%) 53.08s (± 0.59%) ~ 52.48s 53.33s p=0.173 n=6
Emit Time 4.43s (± 1.79%) 4.38s (± 1.83%) ~ 4.25s 4.46s p=0.471 n=6
Total Time 68.93s (± 0.15%) 68.69s (± 0.56%) ~ 67.94s 68.99s p=0.173 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,555 262,554 -1 (- 0.00%) ~ ~ p=0.001 n=6
Types 107,165 107,165 ~ ~ ~ p=1.000 n=6
Memory used 441,803k (± 0.02%) 441,804k (± 0.01%) ~ 441,739k 441,922k p=0.748 n=6
Parse Time 2.90s (± 0.87%) 2.90s (± 0.40%) ~ 2.89s 2.92s p=0.807 n=6
Bind Time 1.11s (± 1.11%) 1.11s ~ ~ ~ p=0.405 n=6
Check Time 15.82s (± 0.30%) 15.82s (± 0.37%) ~ 15.74s 15.91s p=0.936 n=6
Emit Time 1.29s (± 0.94%) 1.32s (± 0.92%) +0.02s (+ 1.80%) 1.30s 1.33s p=0.018 n=6
Total Time 21.13s (± 0.30%) 21.14s (± 0.27%) ~ 21.08s 21.23s p=0.810 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 71 71 ~ ~ ~ p=1.000 n=6
Symbols 225,367 225,367 ~ ~ ~ p=1.000 n=6
Types 94,290 94,290 ~ ~ ~ p=1.000 n=6
Memory used 371,166k (± 0.01%) 371,219k (± 0.08%) ~ 371,065k 371,805k p=0.230 n=6
Parse Time 2.89s (± 1.78%) 2.89s (± 1.02%) ~ 2.86s 2.93s p=1.000 n=6
Bind Time 1.61s (± 1.04%) 1.60s (± 1.66%) ~ 1.58s 1.65s p=0.220 n=6
Check Time 16.42s (± 0.25%) 16.45s (± 0.57%) ~ 16.32s 16.61s p=0.421 n=6
Emit Time 0.00s (±154.76%) 0.00s (±244.70%) ~ 0.00s 0.01s p=0.595 n=6
Total Time 20.93s (± 0.40%) 20.94s (± 0.61%) ~ 20.81s 21.18s p=0.936 n=6
vscode - node (v18.15.0, x64)
Errors 1 1 ~ ~ ~ p=1.000 n=6
Symbols 3,849,869 3,849,869 ~ ~ ~ p=1.000 n=6
Types 1,213,347 1,213,347 ~ ~ ~ p=1.000 n=6
Memory used 3,682,548k (± 0.00%) 3,682,491k (± 0.01%) ~ 3,682,145k 3,682,800k p=1.000 n=6
Parse Time 18.80s (± 0.72%) 18.82s (± 0.44%) ~ 18.75s 18.98s p=0.294 n=6
Bind Time 6.05s (± 2.45%) 6.03s (± 0.64%) ~ 5.97s 6.08s p=0.375 n=6
Check Time 122.31s (± 0.93%) 125.06s (± 2.46%) ~ 121.54s 129.76s p=0.173 n=6
Emit Time 38.62s (± 8.47%) 39.93s (±10.19%) ~ 37.17s 45.24s p=0.936 n=6
Total Time 185.78s (± 2.34%) 189.84s (± 2.91%) ~ 183.78s 196.33s p=0.230 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 320,509 320,509 ~ ~ ~ p=1.000 n=6
Types 139,248 139,248 ~ ~ ~ p=1.000 n=6
Memory used 477,062k (± 0.02%) 477,099k (± 0.03%) ~ 476,858k 477,237k p=0.575 n=6
Parse Time 4.34s (± 0.91%) 4.35s (± 0.40%) ~ 4.33s 4.38s p=0.572 n=6
Bind Time 1.83s (± 1.75%) 1.84s (± 1.47%) ~ 1.80s 1.87s p=0.746 n=6
Check Time 21.10s (± 0.40%) 21.14s (± 0.49%) ~ 21.02s 21.27s p=0.521 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.27s (± 0.44%) 27.34s (± 0.41%) ~ 27.21s 27.48s p=0.261 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 663,768 663,768 ~ ~ ~ p=1.000 n=6
Types 198,416 198,416 ~ ~ ~ p=1.000 n=6
Memory used 570,464k (± 0.01%) 570,695k (± 0.02%) +231k (+ 0.04%) 570,492k 570,829k p=0.016 n=6
Parse Time 4.30s (± 1.09%) 4.29s (± 0.73%) ~ 4.25s 4.34s p=1.000 n=6
Bind Time 1.33s (± 1.20%) 1.33s (± 0.56%) ~ 1.32s 1.34s p=0.801 n=6
Check Time 20.69s (± 0.93%) 20.14s (± 1.79%) -0.55s (- 2.64%) 19.82s 20.64s p=0.045 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 26.32s (± 0.86%) 25.77s (± 1.45%) -0.55s (- 2.10%) 25.48s 26.30s p=0.045 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

@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62283/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
Status: Not started
Development

Successfully merging this pull request may close these issues.

3 participants