GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CFA for dependent parameters typed by generic constraints by ahejlsberg · Pull Request #48411 · microsoft/TypeScript

Conversation

@ahejlsberg

@ahejlsberg Anders Hejlsberg (ahejlsberg) commented Mar 24, 2022

Copy link
Copy Markdown
Member

Fixes #48345.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

awerlogus reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Anders Hejlsberg (ahejlsberg) added 2 commits March 24, 2022 16:41
@ahejlsberg
Obtain apparent type in parameter destructuring check
70f6175
@ahejlsberg
Add regression test
44e8d72
@typescript-bot TypeScript Bot (typescript-bot) assigned Anders Hejlsberg (ahejlsberg) Mar 24, 2022
@typescript-bot TypeScript Bot (typescript-bot) added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Mar 24, 2022
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Mar 24, 2022

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test this
TypeScript Bot (@typescript-bot) user test this inline
TypeScript Bot (@typescript-bot) run dt
TypeScript Bot (@typescript-bot) perf test faster

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based community code test suite on this PR at 44e8d72. You can monitor the build here.

Update: The results are in!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 44e8d72. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at 44e8d72. You can monitor the build here.

Update: The results are in!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 44e8d72. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ahejlsberg
Anders Hejlsberg (ahejlsberg) requested a review from Ryan Cavanaugh (RyanCavanaugh) March 24, 2022 23:53
@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 25, 2022

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..48411

Metric main 48411 Delta Best Worst
Angular - node (v14.15.1, x64)
Memory used 332,462k (± 0.01%) 332,480k (± 0.01%) +18k (+ 0.01%) 332,434k 332,546k
Parse Time 2.02s (± 0.45%) 2.02s (± 0.24%) -0.00s (- 0.10%) 2.01s 2.03s
Bind Time 0.87s (± 0.60%) 0.87s (± 0.92%) -0.00s (- 0.12%) 0.85s 0.89s
Check Time 5.61s (± 0.42%) 5.61s (± 0.44%) +0.00s (+ 0.02%) 5.55s 5.66s
Emit Time 6.25s (± 0.44%) 6.29s (± 0.58%) +0.04s (+ 0.61%) 6.20s 6.37s
Total Time 14.75s (± 0.30%) 14.79s (± 0.38%) +0.04s (+ 0.25%) 14.64s 14.89s
Compiler-Unions - node (v14.15.1, x64)
Memory used 194,944k (± 0.38%) 194,520k (± 0.56%) -424k (- 0.22%) 191,255k 195,285k
Parse Time 0.86s (± 0.75%) 0.86s (± 0.61%) +0.00s (+ 0.12%) 0.85s 0.87s
Bind Time 0.56s (± 0.80%) 0.56s (± 0.80%) 0.00s ( 0.00%) 0.55s 0.57s
Check Time 7.51s (± 0.64%) 7.54s (± 0.65%) +0.03s (+ 0.36%) 7.46s 7.67s
Emit Time 2.50s (± 0.86%) 2.49s (± 0.79%) -0.01s (- 0.28%) 2.45s 2.54s
Total Time 11.42s (± 0.46%) 11.45s (± 0.42%) +0.02s (+ 0.18%) 11.38s 11.57s
Monaco - node (v14.15.1, x64)
Memory used 325,416k (± 0.01%) 325,425k (± 0.01%) +9k (+ 0.00%) 325,391k 325,474k
Parse Time 1.58s (± 0.60%) 1.57s (± 0.25%) -0.01s (- 0.44%) 1.56s 1.58s
Bind Time 0.77s (± 0.38%) 0.77s (± 0.64%) +0.00s (+ 0.26%) 0.77s 0.79s
Check Time 5.51s (± 0.28%) 5.49s (± 0.53%) -0.02s (- 0.38%) 5.40s 5.54s
Emit Time 3.31s (± 0.51%) 3.29s (± 0.61%) -0.02s (- 0.64%) 3.24s 3.32s
Total Time 11.17s (± 0.20%) 11.12s (± 0.31%) -0.05s (- 0.43%) 11.00s 11.18s
TFS - node (v14.15.1, x64)
Memory used 288,905k (± 0.01%) 288,894k (± 0.00%) -11k (- 0.00%) 288,853k 288,911k
Parse Time 1.32s (± 1.17%) 1.32s (± 1.58%) +0.00s (+ 0.23%) 1.29s 1.38s
Bind Time 0.73s (± 0.92%) 0.73s (± 0.64%) +0.00s (+ 0.41%) 0.72s 0.74s
Check Time 5.15s (± 0.38%) 5.16s (± 0.49%) +0.00s (+ 0.10%) 5.08s 5.21s
Emit Time 3.45s (± 1.71%) 3.50s (± 2.32%) +0.05s (+ 1.42%) 3.36s 3.66s
Total Time 10.65s (± 0.62%) 10.71s (± 1.08%) +0.06s (+ 0.56%) 10.48s 10.95s
material-ui - node (v14.15.1, x64)
Memory used 453,635k (± 0.01%) 453,586k (± 0.04%) -48k (- 0.01%) 452,939k 453,713k
Parse Time 1.86s (± 0.26%) 1.85s (± 0.41%) -0.00s (- 0.11%) 1.84s 1.88s
Bind Time 0.71s (± 0.91%) 0.70s (± 1.08%) -0.00s (- 0.56%) 0.69s 0.72s
Check Time 20.38s (± 0.70%) 20.51s (± 0.64%) +0.13s (+ 0.62%) 20.33s 20.88s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 22.95s (± 0.62%) 23.07s (± 0.60%) +0.12s (+ 0.51%) 22.89s 23.48s
xstate - node (v14.15.1, x64)
Memory used 534,101k (± 0.00%) 534,087k (± 0.00%) -14k (- 0.00%) 534,043k 534,118k
Parse Time 2.56s (± 0.38%) 2.57s (± 0.48%) +0.00s (+ 0.20%) 2.54s 2.60s
Bind Time 1.15s (± 0.66%) 1.15s (± 0.72%) +0.00s (+ 0.09%) 1.13s 1.17s
Check Time 1.51s (± 0.40%) 1.52s (± 0.49%) +0.01s (+ 0.33%) 1.51s 1.54s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.29s (± 0.17%) 5.31s (± 0.35%) +0.01s (+ 0.26%) 5.27s 5.36s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory4 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 48411 10
Baseline main 10

Developer Information:

Download Benchmark

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 25, 2022

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
Great news! no new errors were found between main..refs/pull/48411/merge

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Andarist
Mateusz Burzyński (Andarist) reviewed Mar 25, 2022
View reviewed changes
Comment thread src/compiler/checker.ts
const contextualSignature = getContextualSignature(func);
if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
const restType = getTypeOfSymbol(contextualSignature.parameters[0]);
const restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0]));

@Andarist Mateusz Burzyński (Andarist) Mar 25, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

A very easy fix indeed 😅

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ahejlsberg
Merge branch 'main' into fix48345
342116c
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Mar 25, 2022

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) run dt

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@awerlogus

Michael Borislav (awerlogus) commented Mar 25, 2022

Copy link
Copy Markdown

For test suite:

function a<T extends 'a' | 'b'> (arg: T) {
  if (arg === 'a') {
    // Expected: 'a'
    // Got: T extends "a" | "b"
    arg
  }
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) approved these changes Mar 30, 2022
View reviewed changes
@ahejlsberg
Anders Hejlsberg (ahejlsberg) merged commit fd601dd into main Mar 30, 2022
@ahejlsberg
Anders Hejlsberg (ahejlsberg) deleted the fix48345 branch March 30, 2022 23:33
Sidharth Vinod (sidharthv96) added a commit to sidharthv96/TypeScript that referenced this pull request Apr 1, 2022
@sidharthv96
Merge remote-tracking branch 'upstream/main' into fix/46149
e149cc3
* upstream/main: (473 commits)
  Correct node used for isDefinition calculation (microsoft#48499)
  fix(48405): emit dummy members from a mapped type (microsoft#48481)
  CFA for dependent parameters typed by generic constraints (microsoft#48411)
  No contextual typing from return types for boolean literals (microsoft#48380)
  fix(47733): omit JSDoc comment template suggestion on node with existing JSDoc (microsoft#47748)
  Ensure that we copy empty NodeArrays during transform (microsoft#48490)
  Add a new compiler option `moduleSuffixes` to expand the node module resolver's search algorithm (microsoft#48189)
  feat(27615): Add missing member fix should work for type literals (microsoft#47212)
  Add label details to completion entry (microsoft#48429)
  Enable method signature completion for object literals (microsoft#48168)
  Fix string literal completions when a partially-typed string fixes inference to a type parameter (microsoft#48410)
  fix(48445): show errors on type-only import/export specifiers in JavaScript files (microsoft#48449)
  Fix newline inserted in empty block at end of formatting range (microsoft#48463)
  Prevent looking up symbol for as const from triggering an error (microsoft#48464)
  Revise accessor resolution logic and error reporting (microsoft#48459)
  fix(48166): skip checking module.exports in a truthiness call expression (microsoft#48337)
  LEGO: Merge pull request 48450
  LEGO: Merge pull request 48436
  fix(48031): show circularity error for self referential get accessor annotations (microsoft#48050)
  Revert "Fix contextual discrimination for omitted members (microsoft#43937)" (microsoft#48426)
  ...
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) RyanCavanaugh approved these changes
+1 more reviewer
@Andarist Mateusz Burzyński (Andarist) Andarist left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@ahejlsberg Anders Hejlsberg (ahejlsberg)

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Control Flow Analysis for Dependent Parameters doesn't work when the parameters are generic

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@ahejlsberg @typescript-bot @awerlogus @RyanCavanaugh @Andarist
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.