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

Fix string literal completions when a partially-typed string fixes inference to a type parameter #48410

Merged
merged 2 commits into from Mar 29, 2022

Conversation

andrewbranch
Copy link
Member

Fixes #43646

Very involved with #36556

…ference to a type parameter

Ugghhghgh

Revert "Ugghhghgh"

This reverts commit cad98b9.

FSDjkl;afsdjklsfdjksdfkjjk

Revert "FSDjkl;afsdjklsfdjksdfkjjk"

This reverts commit 0cc19c6.

Revert "Revert "Ugghhghgh""

This reverts commit 44434a3.

It works
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Mar 24, 2022
@@ -22662,7 +22675,7 @@ namespace ts {
const properties = getPropertiesOfObjectType(target);
for (const targetProp of properties) {
const sourceProp = getPropertyOfType(source, targetProp.escapedName);
if (sourceProp) {
if (sourceProp && !some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it would be nice to skip this at least in non-services calls, but it would be a lot of plumbing to get checkMode through. I can make a local in createTypeChecker if it seems worthwhile.

Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure you could translate the CheckMode to an InferenceFlag if you'd like.

Copy link
Member Author

Choose a reason for hiding this comment

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

inferTypes doesn’t have access to the inference flags, so this doesn’t actually improve the plumbing situation 😕

Copy link
Member

Choose a reason for hiding this comment

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

A dummy InferencePriority that's unset by the start of inference then? 😅

@@ -570,6 +555,8 @@ namespace ts {
getFullyQualifiedName,
getResolvedSignature: (node, candidatesOutArray, argumentCount) =>
getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.Normal),
getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray) =>
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just add an @internal overload for getResolvedSignature that allows CheckMode to be passed in?

Copy link
Member Author

Choose a reason for hiding this comment

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

editingArgument is also needed, and argumentCount isn’t needed... and I like that the name implies the signature you’re going to get is in fact not at all the same signature you would get for normal checking purposes.

@andrewbranch
Copy link
Member Author

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 29, 2022

Heya @andrewbranch, I've started to run the perf test suite on this PR at 0d266cd. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..48410

Metric main 48410 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 356,670k (± 0.02%) 356,651k (± 0.03%) -19k (- 0.01%) 356,488k 356,857k
Parse Time 2.06s (± 0.48%) 2.06s (± 0.75%) +0.00s (+ 0.10%) 2.02s 2.09s
Bind Time 0.86s (± 0.55%) 0.86s (± 0.86%) 0.00s ( 0.00%) 0.85s 0.88s
Check Time 5.81s (± 0.33%) 5.81s (± 0.62%) +0.01s (+ 0.14%) 5.76s 5.91s
Emit Time 5.98s (± 0.47%) 5.98s (± 0.56%) +0.00s (+ 0.03%) 5.93s 6.07s
Total Time 14.71s (± 0.24%) 14.72s (± 0.45%) +0.01s (+ 0.07%) 14.58s 14.90s
Compiler-Unions - node (v10.16.3, x64)
Memory used 205,721k (± 0.03%) 205,779k (± 0.04%) +58k (+ 0.03%) 205,622k 205,962k
Parse Time 0.85s (± 0.98%) 0.84s (± 0.40%) -0.00s (- 0.35%) 0.84s 0.85s
Bind Time 0.52s (± 1.00%) 0.52s (± 1.28%) +0.00s (+ 0.77%) 0.51s 0.54s
Check Time 8.00s (± 0.77%) 7.99s (± 0.59%) -0.01s (- 0.09%) 7.89s 8.07s
Emit Time 2.52s (± 1.22%) 2.52s (± 0.61%) -0.00s (- 0.04%) 2.48s 2.55s
Total Time 11.88s (± 0.67%) 11.87s (± 0.42%) -0.01s (- 0.08%) 11.74s 11.95s
Monaco - node (v10.16.3, x64)
Memory used 343,613k (± 0.01%) 343,601k (± 0.01%) -12k (- 0.00%) 343,459k 343,679k
Parse Time 1.58s (± 0.78%) 1.58s (± 0.52%) -0.01s (- 0.38%) 1.56s 1.60s
Bind Time 0.76s (± 0.68%) 0.76s (± 0.63%) -0.00s (- 0.26%) 0.75s 0.77s
Check Time 5.79s (± 0.45%) 5.78s (± 0.41%) -0.01s (- 0.12%) 5.72s 5.85s
Emit Time 3.24s (± 0.47%) 3.24s (± 0.67%) +0.01s (+ 0.28%) 3.20s 3.29s
Total Time 11.36s (± 0.34%) 11.36s (± 0.30%) -0.00s (- 0.03%) 11.29s 11.43s
TFS - node (v10.16.3, x64)
Memory used 305,287k (± 0.02%) 305,290k (± 0.02%) +3k (+ 0.00%) 305,122k 305,433k
Parse Time 1.29s (± 0.47%) 1.28s (± 0.53%) -0.00s (- 0.08%) 1.27s 1.30s
Bind Time 0.72s (± 0.92%) 0.72s (± 0.93%) -0.00s (- 0.42%) 0.70s 0.73s
Check Time 5.24s (± 0.48%) 5.25s (± 0.55%) +0.00s (+ 0.10%) 5.19s 5.31s
Emit Time 3.41s (± 0.90%) 3.43s (± 1.03%) +0.02s (+ 0.47%) 3.36s 3.50s
Total Time 10.66s (± 0.39%) 10.68s (± 0.47%) +0.01s (+ 0.13%) 10.58s 10.81s
material-ui - node (v10.16.3, x64)
Memory used 469,585k (± 0.01%) 469,833k (± 0.01%) +248k (+ 0.05%) 469,748k 469,958k
Parse Time 1.83s (± 0.45%) 1.81s (± 0.50%) -0.01s (- 0.77%) 1.79s 1.84s
Bind Time 0.68s (± 0.76%) 0.68s (± 0.50%) +0.00s (+ 0.29%) 0.68s 0.69s
Check Time 14.34s (± 0.57%) 14.29s (± 0.49%) -0.05s (- 0.35%) 14.16s 14.49s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.85s (± 0.51%) 16.78s (± 0.43%) -0.06s (- 0.39%) 16.66s 16.98s
xstate - node (v10.16.3, x64)
Memory used 570,765k (± 0.02%) 574,045k (± 1.25%) +3,280k (+ 0.57%) 570,612k 602,986k
Parse Time 2.58s (± 0.41%) 2.58s (± 0.43%) -0.00s (- 0.00%) 2.57s 2.61s
Bind Time 1.01s (± 0.34%) 1.00s (± 0.50%) -0.01s (- 0.79%) 0.99s 1.01s
Check Time 1.51s (± 0.51%) 1.51s (± 0.59%) +0.00s (+ 0.20%) 1.49s 1.53s
Emit Time 0.07s (± 0.00%) 0.07s (± 3.14%) +0.00s (+ 1.43%) 0.07s 0.08s
Total Time 5.17s (± 0.27%) 5.17s (± 0.26%) -0.00s (- 0.04%) 5.15s 5.20s
Angular - node (v12.1.0, x64)
Memory used 334,442k (± 0.03%) 334,507k (± 0.03%) +66k (+ 0.02%) 334,309k 334,731k
Parse Time 2.06s (± 0.73%) 2.05s (± 0.56%) -0.01s (- 0.34%) 2.03s 2.09s
Bind Time 0.82s (± 0.60%) 0.83s (± 0.81%) +0.00s (+ 0.36%) 0.82s 0.85s
Check Time 5.62s (± 0.59%) 5.65s (± 0.51%) +0.03s (+ 0.48%) 5.59s 5.73s
Emit Time 6.29s (± 1.88%) 6.22s (± 0.71%) -0.08s (- 1.22%) 6.14s 6.34s
Total Time 14.81s (± 0.94%) 14.75s (± 0.44%) -0.06s (- 0.39%) 14.65s 14.89s
Compiler-Unions - node (v12.1.0, x64)
Memory used 193,231k (± 0.10%) 193,283k (± 0.12%) +52k (+ 0.03%) 192,596k 193,546k
Parse Time 0.85s (± 1.20%) 0.85s (± 1.09%) -0.00s (- 0.35%) 0.83s 0.86s
Bind Time 0.54s (± 1.14%) 0.54s (± 1.14%) 0.00s ( 0.00%) 0.53s 0.55s
Check Time 7.51s (± 0.57%) 7.49s (± 0.68%) -0.02s (- 0.28%) 7.38s 7.60s
Emit Time 2.53s (± 1.12%) 2.57s (± 0.99%) +0.04s (+ 1.62%) 2.52s 2.63s
Total Time 11.43s (± 0.60%) 11.44s (± 0.49%) +0.02s (+ 0.15%) 11.34s 11.58s
Monaco - node (v12.1.0, x64)
Memory used 326,566k (± 0.02%) 326,528k (± 0.07%) -38k (- 0.01%) 325,651k 326,749k
Parse Time 1.55s (± 0.94%) 1.55s (± 0.71%) +0.00s (+ 0.06%) 1.52s 1.57s
Bind Time 0.75s (± 1.16%) 0.74s (± 0.66%) -0.00s (- 0.53%) 0.74s 0.76s
Check Time 5.59s (± 0.51%) 5.62s (± 0.51%) +0.03s (+ 0.52%) 5.57s 5.70s
Emit Time 3.25s (± 0.69%) 3.26s (± 1.00%) +0.01s (+ 0.40%) 3.21s 3.34s
Total Time 11.14s (± 0.41%) 11.17s (± 0.51%) +0.03s (+ 0.31%) 11.05s 11.32s
TFS - node (v12.1.0, x64)
Memory used 289,918k (± 0.01%) 289,957k (± 0.02%) +40k (+ 0.01%) 289,834k 290,050k
Parse Time 1.29s (± 0.48%) 1.29s (± 0.89%) -0.00s (- 0.23%) 1.27s 1.32s
Bind Time 0.71s (± 1.32%) 0.71s (± 0.71%) -0.00s (- 0.70%) 0.70s 0.72s
Check Time 5.20s (± 0.61%) 5.18s (± 0.39%) -0.01s (- 0.25%) 5.12s 5.22s
Emit Time 3.47s (± 0.89%) 3.48s (± 0.96%) +0.01s (+ 0.20%) 3.41s 3.56s
Total Time 10.66s (± 0.54%) 10.66s (± 0.44%) -0.01s (- 0.08%) 10.56s 10.75s
material-ui - node (v12.1.0, x64)
Memory used 448,587k (± 0.06%) 448,770k (± 0.07%) +183k (+ 0.04%) 447,907k 449,145k
Parse Time 1.81s (± 0.45%) 1.82s (± 0.69%) +0.01s (+ 0.66%) 1.80s 1.85s
Bind Time 0.64s (± 0.76%) 0.65s (± 0.73%) +0.00s (+ 0.47%) 0.64s 0.66s
Check Time 12.87s (± 0.78%) 12.98s (± 0.41%) +0.11s (+ 0.82%) 12.85s 13.10s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.32s (± 0.64%) 15.44s (± 0.40%) +0.12s (+ 0.80%) 15.29s 15.57s
xstate - node (v12.1.0, x64)
Memory used 536,312k (± 0.02%) 536,312k (± 0.01%) -0k (- 0.00%) 536,199k 536,469k
Parse Time 2.53s (± 0.71%) 2.52s (± 0.56%) -0.01s (- 0.47%) 2.50s 2.57s
Bind Time 1.04s (± 0.50%) 1.04s (± 0.96%) -0.00s (- 0.19%) 1.02s 1.06s
Check Time 1.47s (± 0.57%) 1.47s (± 0.48%) -0.00s (- 0.00%) 1.45s 1.48s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.12s (± 0.43%) 5.09s (± 0.50%) -0.02s (- 0.45%) 5.04s 5.15s
Angular - node (v14.15.1, x64)
Memory used 332,765k (± 0.01%) 332,773k (± 0.01%) +9k (+ 0.00%) 332,709k 332,825k
Parse Time 2.02s (± 0.55%) 2.04s (± 0.64%) +0.01s (+ 0.59%) 2.00s 2.06s
Bind Time 0.87s (± 0.66%) 0.88s (± 0.56%) +0.00s (+ 0.34%) 0.87s 0.89s
Check Time 5.62s (± 0.45%) 5.67s (± 0.37%) +0.06s (+ 1.00%) 5.63s 5.73s
Emit Time 6.27s (± 0.66%) 6.38s (± 0.69%) +0.10s (+ 1.63%) 6.26s 6.48s
Total Time 14.79s (± 0.39%) 14.96s (± 0.33%) +0.17s (+ 1.15%) 14.86s 15.07s
Compiler-Unions - node (v14.15.1, x64)
Memory used 193,340k (± 0.60%) 194,969k (± 0.36%) +1,629k (+ 0.84%) 192,154k 195,338k
Parse Time 0.86s (± 0.26%) 0.86s (± 0.95%) -0.00s (- 0.46%) 0.84s 0.88s
Bind Time 0.56s (± 0.93%) 0.56s (± 0.93%) +0.00s (+ 0.36%) 0.55s 0.57s
Check Time 7.52s (± 0.68%) 7.56s (± 0.55%) +0.04s (+ 0.52%) 7.50s 7.68s
Emit Time 2.51s (± 0.98%) 2.51s (± 0.69%) -0.00s (- 0.04%) 2.47s 2.55s
Total Time 11.45s (± 0.43%) 11.48s (± 0.50%) +0.04s (+ 0.33%) 11.40s 11.66s
Monaco - node (v14.15.1, x64)
Memory used 325,411k (± 0.00%) 325,403k (± 0.01%) -8k (- 0.00%) 325,366k 325,440k
Parse Time 1.58s (± 0.57%) 1.58s (± 0.68%) +0.00s (+ 0.13%) 1.56s 1.61s
Bind Time 0.78s (± 0.90%) 0.78s (± 1.08%) -0.00s (- 0.26%) 0.77s 0.81s
Check Time 5.55s (± 0.48%) 5.51s (± 0.40%) -0.04s (- 0.68%) 5.47s 5.57s
Emit Time 3.32s (± 0.74%) 3.31s (± 0.61%) -0.01s (- 0.18%) 3.27s 3.36s
Total Time 11.23s (± 0.42%) 11.19s (± 0.36%) -0.04s (- 0.38%) 11.10s 11.25s
TFS - node (v14.15.1, x64)
Memory used 288,886k (± 0.01%) 288,920k (± 0.02%) +34k (+ 0.01%) 288,859k 289,034k
Parse Time 1.31s (± 1.19%) 1.32s (± 1.25%) +0.01s (+ 0.61%) 1.29s 1.37s
Bind Time 0.73s (± 0.93%) 0.74s (± 0.99%) +0.00s (+ 0.54%) 0.72s 0.75s
Check Time 5.16s (± 0.36%) 5.17s (± 0.48%) +0.01s (+ 0.27%) 5.11s 5.23s
Emit Time 3.52s (± 2.12%) 3.56s (± 2.28%) +0.04s (+ 0.99%) 3.38s 3.67s
Total Time 10.72s (± 0.81%) 10.79s (± 0.93%) +0.06s (+ 0.57%) 10.56s 10.92s
material-ui - node (v14.15.1, x64)
Memory used 447,075k (± 0.01%) 447,126k (± 0.06%) +51k (+ 0.01%) 446,068k 447,299k
Parse Time 1.87s (± 0.69%) 1.87s (± 0.86%) -0.01s (- 0.37%) 1.84s 1.90s
Bind Time 0.70s (± 0.71%) 0.71s (± 1.31%) +0.00s (+ 0.43%) 0.68s 0.72s
Check Time 13.09s (± 0.70%) 13.06s (± 0.52%) -0.03s (- 0.27%) 12.95s 13.22s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.67s (± 0.57%) 15.63s (± 0.46%) -0.04s (- 0.25%) 15.49s 15.81s
xstate - node (v14.15.1, x64)
Memory used 534,063k (± 0.01%) 534,080k (± 0.00%) +18k (+ 0.00%) 534,048k 534,122k
Parse Time 2.58s (± 0.48%) 2.60s (± 0.65%) +0.02s (+ 0.70%) 2.56s 2.64s
Bind Time 1.15s (± 0.95%) 1.15s (± 0.88%) -0.00s (- 0.26%) 1.12s 1.16s
Check Time 1.51s (± 0.48%) 1.51s (± 0.46%) +0.00s (+ 0.07%) 1.50s 1.53s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.30s (± 0.27%) 5.32s (± 0.30%) +0.02s (+ 0.34%) 5.28s 5.36s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory3 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 48410 10
Baseline main 10

Developer Information:

Download Benchmark

@andrewbranch
Copy link
Member Author

@weswigham the perf impact seems to be lost in the noise, so I’d rather not do something hacky to avoid the check.


verify.completions({ marker: ["ts", "tsx", "js"], exact: ["", "drag", "dragenter"] });
edit.insert("drag");
verify.completions({ marker: ["ts", "tsx", "js"], exact: ["", "drag", "dragenter"] });
Copy link
Member

Choose a reason for hiding this comment

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

Should we also have a test where drag is already entered and we check that we don't output ""? I mean, I guess we should just so we know what our current behavior is, I suppose.

Copy link
Member Author

Choose a reason for hiding this comment

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

We do output "", but editors filter it out. This is intentional, because it means if the user backspaces, the editor doesn’t have to re-request completions given a different prefix.

Copy link
Member Author

Choose a reason for hiding this comment

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

(The test you’re suggesting is already what’s happening on this line)

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, ok, I misread - thanks!

@andrewbranch andrewbranch merged commit 7ec7d6d into microsoft:main Mar 29, 2022
@andrewbranch
Copy link
Member Author

Hah, I didn’t notice that the extended commit message after my git rebase -i gave away my earlier attempts

image

@andrewbranch andrewbranch deleted the bug/43646 branch March 29, 2022 16:09
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.

JavaScript - IntelliSense list doesn't display full suggestions list.
3 participants