Skip to content

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

Merged
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:bug/43646
Mar 29, 2022
Merged

Fix string literal completions when a partially-typed string fixes inference to a type parameter#48410
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:bug/43646

Conversation

@andrewbranch

Copy link
Copy Markdown
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
for (const targetProp of properties) {
const sourceProp = getPropertyOfType(source, targetProp.escapedName);
if (sourceProp) {
if (sourceProp && !some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
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? 😅

getFullyQualifiedName,
getResolvedSignature: (node, candidatesOutArray, argumentCount) =>
getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.Normal),
getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray) =>

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

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

Copy link
Copy Markdown
Contributor

Heya Andrew Branch (@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
Copy Markdown
Contributor

Andrew Branch (@andrewbranch)
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..48410

Metricmain48410DeltaBestWorst
Angular - node (v10.16.3, x64)
Memory used356,670k (± 0.02%)356,651k (± 0.03%)-19k (- 0.01%)356,488k356,857k
Parse Time2.06s (± 0.48%)2.06s (± 0.75%)+0.00s (+ 0.10%)2.02s2.09s
Bind Time0.86s (± 0.55%)0.86s (± 0.86%)0.00s ( 0.00%)0.85s0.88s
Check Time5.81s (± 0.33%)5.81s (± 0.62%)+0.01s (+ 0.14%)5.76s5.91s
Emit Time5.98s (± 0.47%)5.98s (± 0.56%)+0.00s (+ 0.03%)5.93s6.07s
Total Time14.71s (± 0.24%)14.72s (± 0.45%)+0.01s (+ 0.07%)14.58s14.90s
Compiler-Unions - node (v10.16.3, x64)
Memory used205,721k (± 0.03%)205,779k (± 0.04%)+58k (+ 0.03%)205,622k205,962k
Parse Time0.85s (± 0.98%)0.84s (± 0.40%)-0.00s (- 0.35%)0.84s0.85s
Bind Time0.52s (± 1.00%)0.52s (± 1.28%)+0.00s (+ 0.77%)0.51s0.54s
Check Time8.00s (± 0.77%)7.99s (± 0.59%)-0.01s (- 0.09%)7.89s8.07s
Emit Time2.52s (± 1.22%)2.52s (± 0.61%)-0.00s (- 0.04%)2.48s2.55s
Total Time11.88s (± 0.67%)11.87s (± 0.42%)-0.01s (- 0.08%)11.74s11.95s
Monaco - node (v10.16.3, x64)
Memory used343,613k (± 0.01%)343,601k (± 0.01%)-12k (- 0.00%)343,459k343,679k
Parse Time1.58s (± 0.78%)1.58s (± 0.52%)-0.01s (- 0.38%)1.56s1.60s
Bind Time0.76s (± 0.68%)0.76s (± 0.63%)-0.00s (- 0.26%)0.75s0.77s
Check Time5.79s (± 0.45%)5.78s (± 0.41%)-0.01s (- 0.12%)5.72s5.85s
Emit Time3.24s (± 0.47%)3.24s (± 0.67%)+0.01s (+ 0.28%)3.20s3.29s
Total Time11.36s (± 0.34%)11.36s (± 0.30%)-0.00s (- 0.03%)11.29s11.43s
TFS - node (v10.16.3, x64)
Memory used305,287k (± 0.02%)305,290k (± 0.02%)+3k (+ 0.00%)305,122k305,433k
Parse Time1.29s (± 0.47%)1.28s (± 0.53%)-0.00s (- 0.08%)1.27s1.30s
Bind Time0.72s (± 0.92%)0.72s (± 0.93%)-0.00s (- 0.42%)0.70s0.73s
Check Time5.24s (± 0.48%)5.25s (± 0.55%)+0.00s (+ 0.10%)5.19s5.31s
Emit Time3.41s (± 0.90%)3.43s (± 1.03%)+0.02s (+ 0.47%)3.36s3.50s
Total Time10.66s (± 0.39%)10.68s (± 0.47%)+0.01s (+ 0.13%)10.58s10.81s
material-ui - node (v10.16.3, x64)
Memory used469,585k (± 0.01%)469,833k (± 0.01%)+248k (+ 0.05%)469,748k469,958k
Parse Time1.83s (± 0.45%)1.81s (± 0.50%)-0.01s (- 0.77%)1.79s1.84s
Bind Time0.68s (± 0.76%)0.68s (± 0.50%)+0.00s (+ 0.29%)0.68s0.69s
Check Time14.34s (± 0.57%)14.29s (± 0.49%)-0.05s (- 0.35%)14.16s14.49s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time16.85s (± 0.51%)16.78s (± 0.43%)-0.06s (- 0.39%)16.66s16.98s
xstate - node (v10.16.3, x64)
Memory used570,765k (± 0.02%)574,045k (± 1.25%)+3,280k (+ 0.57%)570,612k602,986k
Parse Time2.58s (± 0.41%)2.58s (± 0.43%)-0.00s (- 0.00%)2.57s2.61s
Bind Time1.01s (± 0.34%)1.00s (± 0.50%)-0.01s (- 0.79%)0.99s1.01s
Check Time1.51s (± 0.51%)1.51s (± 0.59%)+0.00s (+ 0.20%)1.49s1.53s
Emit Time0.07s (± 0.00%)0.07s (± 3.14%)+0.00s (+ 1.43%)0.07s0.08s
Total Time5.17s (± 0.27%)5.17s (± 0.26%)-0.00s (- 0.04%)5.15s5.20s
Angular - node (v12.1.0, x64)
Memory used334,442k (± 0.03%)334,507k (± 0.03%)+66k (+ 0.02%)334,309k334,731k
Parse Time2.06s (± 0.73%)2.05s (± 0.56%)-0.01s (- 0.34%)2.03s2.09s
Bind Time0.82s (± 0.60%)0.83s (± 0.81%)+0.00s (+ 0.36%)0.82s0.85s
Check Time5.62s (± 0.59%)5.65s (± 0.51%)+0.03s (+ 0.48%)5.59s5.73s
Emit Time6.29s (± 1.88%)6.22s (± 0.71%)-0.08s (- 1.22%)6.14s6.34s
Total Time14.81s (± 0.94%)14.75s (± 0.44%)-0.06s (- 0.39%)14.65s14.89s
Compiler-Unions - node (v12.1.0, x64)
Memory used193,231k (± 0.10%)193,283k (± 0.12%)+52k (+ 0.03%)192,596k193,546k
Parse Time0.85s (± 1.20%)0.85s (± 1.09%)-0.00s (- 0.35%)0.83s0.86s
Bind Time0.54s (± 1.14%)0.54s (± 1.14%)0.00s ( 0.00%)0.53s0.55s
Check Time7.51s (± 0.57%)7.49s (± 0.68%)-0.02s (- 0.28%)7.38s7.60s
Emit Time2.53s (± 1.12%)2.57s (± 0.99%)+0.04s (+ 1.62%)2.52s2.63s
Total Time11.43s (± 0.60%)11.44s (± 0.49%)+0.02s (+ 0.15%)11.34s11.58s
Monaco - node (v12.1.0, x64)
Memory used326,566k (± 0.02%)326,528k (± 0.07%)-38k (- 0.01%)325,651k326,749k
Parse Time1.55s (± 0.94%)1.55s (± 0.71%)+0.00s (+ 0.06%)1.52s1.57s
Bind Time0.75s (± 1.16%)0.74s (± 0.66%)-0.00s (- 0.53%)0.74s0.76s
Check Time5.59s (± 0.51%)5.62s (± 0.51%)+0.03s (+ 0.52%)5.57s5.70s
Emit Time3.25s (± 0.69%)3.26s (± 1.00%)+0.01s (+ 0.40%)3.21s3.34s
Total Time11.14s (± 0.41%)11.17s (± 0.51%)+0.03s (+ 0.31%)11.05s11.32s
TFS - node (v12.1.0, x64)
Memory used289,918k (± 0.01%)289,957k (± 0.02%)+40k (+ 0.01%)289,834k290,050k
Parse Time1.29s (± 0.48%)1.29s (± 0.89%)-0.00s (- 0.23%)1.27s1.32s
Bind Time0.71s (± 1.32%)0.71s (± 0.71%)-0.00s (- 0.70%)0.70s0.72s
Check Time5.20s (± 0.61%)5.18s (± 0.39%)-0.01s (- 0.25%)5.12s5.22s
Emit Time3.47s (± 0.89%)3.48s (± 0.96%)+0.01s (+ 0.20%)3.41s3.56s
Total Time10.66s (± 0.54%)10.66s (± 0.44%)-0.01s (- 0.08%)10.56s10.75s
material-ui - node (v12.1.0, x64)
Memory used448,587k (± 0.06%)448,770k (± 0.07%)+183k (+ 0.04%)447,907k449,145k
Parse Time1.81s (± 0.45%)1.82s (± 0.69%)+0.01s (+ 0.66%)1.80s1.85s
Bind Time0.64s (± 0.76%)0.65s (± 0.73%)+0.00s (+ 0.47%)0.64s0.66s
Check Time12.87s (± 0.78%)12.98s (± 0.41%)+0.11s (+ 0.82%)12.85s13.10s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.32s (± 0.64%)15.44s (± 0.40%)+0.12s (+ 0.80%)15.29s15.57s
xstate - node (v12.1.0, x64)
Memory used536,312k (± 0.02%)536,312k (± 0.01%)-0k (- 0.00%)536,199k536,469k
Parse Time2.53s (± 0.71%)2.52s (± 0.56%)-0.01s (- 0.47%)2.50s2.57s
Bind Time1.04s (± 0.50%)1.04s (± 0.96%)-0.00s (- 0.19%)1.02s1.06s
Check Time1.47s (± 0.57%)1.47s (± 0.48%)-0.00s (- 0.00%)1.45s1.48s
Emit Time0.07s (± 0.00%)0.07s (± 0.00%)0.00s ( 0.00%)0.07s0.07s
Total Time5.12s (± 0.43%)5.09s (± 0.50%)-0.02s (- 0.45%)5.04s5.15s
Angular - node (v14.15.1, x64)
Memory used332,765k (± 0.01%)332,773k (± 0.01%)+9k (+ 0.00%)332,709k332,825k
Parse Time2.02s (± 0.55%)2.04s (± 0.64%)+0.01s (+ 0.59%)2.00s2.06s
Bind Time0.87s (± 0.66%)0.88s (± 0.56%)+0.00s (+ 0.34%)0.87s0.89s
Check Time5.62s (± 0.45%)5.67s (± 0.37%)+0.06s (+ 1.00%)5.63s5.73s
Emit Time6.27s (± 0.66%)6.38s (± 0.69%)+0.10s (+ 1.63%)6.26s6.48s
Total Time14.79s (± 0.39%)14.96s (± 0.33%)+0.17s (+ 1.15%)14.86s15.07s
Compiler-Unions - node (v14.15.1, x64)
Memory used193,340k (± 0.60%)194,969k (± 0.36%)+1,629k (+ 0.84%)192,154k195,338k
Parse Time0.86s (± 0.26%)0.86s (± 0.95%)-0.00s (- 0.46%)0.84s0.88s
Bind Time0.56s (± 0.93%)0.56s (± 0.93%)+0.00s (+ 0.36%)0.55s0.57s
Check Time7.52s (± 0.68%)7.56s (± 0.55%)+0.04s (+ 0.52%)7.50s7.68s
Emit Time2.51s (± 0.98%)2.51s (± 0.69%)-0.00s (- 0.04%)2.47s2.55s
Total Time11.45s (± 0.43%)11.48s (± 0.50%)+0.04s (+ 0.33%)11.40s11.66s
Monaco - node (v14.15.1, x64)
Memory used325,411k (± 0.00%)325,403k (± 0.01%)-8k (- 0.00%)325,366k325,440k
Parse Time1.58s (± 0.57%)1.58s (± 0.68%)+0.00s (+ 0.13%)1.56s1.61s
Bind Time0.78s (± 0.90%)0.78s (± 1.08%)-0.00s (- 0.26%)0.77s0.81s
Check Time5.55s (± 0.48%)5.51s (± 0.40%)-0.04s (- 0.68%)5.47s5.57s
Emit Time3.32s (± 0.74%)3.31s (± 0.61%)-0.01s (- 0.18%)3.27s3.36s
Total Time11.23s (± 0.42%)11.19s (± 0.36%)-0.04s (- 0.38%)11.10s11.25s
TFS - node (v14.15.1, x64)
Memory used288,886k (± 0.01%)288,920k (± 0.02%)+34k (+ 0.01%)288,859k289,034k
Parse Time1.31s (± 1.19%)1.32s (± 1.25%)+0.01s (+ 0.61%)1.29s1.37s
Bind Time0.73s (± 0.93%)0.74s (± 0.99%)+0.00s (+ 0.54%)0.72s0.75s
Check Time5.16s (± 0.36%)5.17s (± 0.48%)+0.01s (+ 0.27%)5.11s5.23s
Emit Time3.52s (± 2.12%)3.56s (± 2.28%)+0.04s (+ 0.99%)3.38s3.67s
Total Time10.72s (± 0.81%)10.79s (± 0.93%)+0.06s (+ 0.57%)10.56s10.92s
material-ui - node (v14.15.1, x64)
Memory used447,075k (± 0.01%)447,126k (± 0.06%)+51k (+ 0.01%)446,068k447,299k
Parse Time1.87s (± 0.69%)1.87s (± 0.86%)-0.01s (- 0.37%)1.84s1.90s
Bind Time0.70s (± 0.71%)0.71s (± 1.31%)+0.00s (+ 0.43%)0.68s0.72s
Check Time13.09s (± 0.70%)13.06s (± 0.52%)-0.03s (- 0.27%)12.95s13.22s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.67s (± 0.57%)15.63s (± 0.46%)-0.04s (- 0.25%)15.49s15.81s
xstate - node (v14.15.1, x64)
Memory used534,063k (± 0.01%)534,080k (± 0.00%)+18k (+ 0.00%)534,048k534,122k
Parse Time2.58s (± 0.48%)2.60s (± 0.65%)+0.02s (+ 0.70%)2.56s2.64s
Bind Time1.15s (± 0.95%)1.15s (± 0.88%)-0.00s (- 0.26%)1.12s1.16s
Check Time1.51s (± 0.48%)1.51s (± 0.46%)+0.00s (+ 0.07%)1.50s1.53s
Emit Time0.07s (± 0.00%)0.07s (± 0.00%)0.00s ( 0.00%)0.07s0.07s
Total Time5.30s (± 0.27%)5.32s (± 0.30%)+0.02s (+ 0.34%)5.28s5.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)
BenchmarkNameIterations
Current4841010
Baselinemain10

Developer Information:

Download Benchmark

@andrewbranch

Copy link
Copy Markdown
MemberAuthor

Wesley Wigham (@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"] }); No newline at end of file

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Andrew Branch (andrewbranch) merged commit 7ec7d6d into microsoft:mainMar 29, 2022
@andrewbranch

Copy link
Copy Markdown
MemberAuthor

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

image

Sidharth Vinod (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)
...
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: TeamFor Milestone BugPRs 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

@andrewbranch@typescript-bot@weswigham