Skip to content
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

CFA for dependent parameters typed by generic constraints #48411

Merged
merged 3 commits into from
Mar 30, 2022
Merged

Conversation

ahejlsberg
Copy link
Member

Fixes #48345.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Mar 24, 2022
@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this inline
@typescript-bot run dt
@typescript-bot perf test faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2022

Heya @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!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2022

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2022

Heya @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!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2022

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

@typescript-bot
Copy link
Collaborator

@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

@typescript-bot
Copy link
Collaborator

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

@@ -25424,7 +25424,7 @@ namespace ts {
if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
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]));
Copy link
Contributor

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 😅

@ahejlsberg
Copy link
Member Author

@typescript-bot run dt

@awerlogus
Copy link

For test suite:

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

@ahejlsberg ahejlsberg merged commit fd601dd into main Mar 30, 2022
@ahejlsberg ahejlsberg deleted the fix48345 branch March 30, 2022 23:33
sidharthv96 added a commit to sidharthv96/TypeScript that referenced this pull request Apr 1, 2022
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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