Skip to content

Fix(52604): Provide Object member completions without comma; insert a comma - #52899

Merged
Daniel Rosenwasser (DanielRosenwasser) merged 18 commits into
mainfrom
fix(52604)
Jun 27, 2023
Merged

Fix(52604): Provide Object member completions without comma; insert a comma#52899
Daniel Rosenwasser (DanielRosenwasser) merged 18 commits into
mainfrom
fix(52604)

Conversation

@navya9singh

Copy link
Copy Markdown
Member

This pr provides object member completion with a missing comma and inserts a comma as well. It inserts comma in cases when insertion is requested on the same line, color: {primary: "red" /*$*/} or on different lines,

interface ColorPalette {
primary?: string;
secondary?: string;
}
let colors: ColorPalette = {
primary: "red"
/*$*/
};

and excludes cases which do not need a comma, like const i: I = {/*$*/}; or

interface I { e: E }
const i: I = { e: /*$*/}; 

Fixes#52604

@typescript-botTypeScript Bot (typescript-bot) added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 21, 2023
@navya9singhnavya9singh changed the title Fix(52604)Fix(52604): Provide Object member completions without comma; insert a commaFeb 21, 2023

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.

Nice work, this is 90% of the way there. Just a few things to clean up.

Comment threadsrc/services/completions.ts Outdated
Comment threadsrc/services/completions.ts Outdated
Comment threadsrc/services/completions.ts Outdated
Comment threadsrc/services/completions.ts Outdated
/** Case completions for switch statements */
SwitchCases = "SwitchCases/",
/** Completions for an Object literal expression */
ObjectLiteralExpression = "ObjectLiteralExpression/",

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.

The name of this should indicate that it’s for comma insertion. ObjectLiteralMemberWithComma or something

Comment threadsrc/services/textChanges.ts Outdated
this.replaceNode(sourceFile, oldNode, newNode, { suffix });
}

public replacePropertyAssignmentOnSameLine(sourceFile: SourceFile, oldNode: PropertyAssignment, newNode: PropertyAssignment): void {

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.

This is no longer used.

},
"Add missing comma for an object member completion '{0}'.": {
"category": "Message",
"code": 18052

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.

Although I don’t care as much about diagnostic message grouping as Jake does, it’s still nice to separate the Messages from the Errors. There should be a group that’s entirely Message category.

Comment threadsrc/services/completions.ts Outdated
if (source === CompletionSource.ObjectLiteralExpression && contextToken) {
const changes = textChanges.ChangeTracker.with(
{ host, formatContext, preferences },
tracker=>tracker.insertText(sourceFile, contextToken.end,","));

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.

Suggested change
tracker=>tracker.insertText(sourceFile,contextToken.end,","));
tracker=>tracker.insertText(sourceFile,contextToken.end,","));

@andrewbranch

Copy link
Copy Markdown
Member

I wonder if this works on the playground 🤔

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 23, 2023

Copy link
Copy Markdown
Contributor

Heya Andrew Branch (@andrewbranch), I've started to run the tarball bundle task on this PR at c8c1362. You can monitor the build here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Andrew Branch (@andrewbranch), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/147364/artifacts?artifactName=tgz&fileId=620A7AB184D9BE999EF44C53CE7209DBF6DB8D3FE86AA5C352936B9EEADF635E02&fileName=/typescript-5.0.0-insiders.20230223.tgz"
}
}

and then running npm install.

Comment threadsrc/services/completions.ts Outdated
Comment on lines +1357 to +1358
if ((contextToken && isPropertyAssignment(contextToken.parent) && findNextToken(contextToken, contextToken?.parent, sourceFile)?.kind !== SyntaxKind.CommaToken &&
completionKind === CompletionKind.ObjectPropertyDeclaration)) {

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.

completionKind === CompletionKind.ObjectPropertyDeclaration is the cheapest of these conditions to check (along with contextToken), so it should be moved before the more expensive ones (particularly the findNextToken call) so the harder work can be short-circuited.

(Also, it looks like there’s an extra pair of parens around this whole expression.)

@gabritto

Copy link
Copy Markdown
Member

I saw that Navya already commented about this on the other issue, but before shipping this we should really fix microsoft/vscode#174628 or at least update the code to distinguish between sources.

@gabritto

Copy link
Copy Markdown
Member

Another issue I found testing this: we don't do the comma insertion for object literal method snippet completions, only for the regular object literal completions:

interfaceT{aaa: string;foo(): void;}constobj: T={aaa: ""/**/}

If you select the completion that inserts just foo, then the comma is inserted. But if you select the snippet completion foo(), the comma is not inserted.

@gabritto

Gabriela Araujo Britto (gabritto) commented Feb 23, 2023

Copy link
Copy Markdown
Member

Something else I noticed that doesn't work is that we don't offer object literal completions after a commaless method, or in fact after a property assignment with a more complex expression:

interfaceT{aaa: string;bbb: number;foo(): void;}constobj: T={foo(){}/**/}constobj: T={bbb: 1*2/**/}

You get the global completions here instead.

@andrewbranch

Copy link
Copy Markdown
Member

Hm, good catch. The infrastructure we have now may not be conducive to combining the snippet and the comma insertion, since each has its own CompletionEntrySource value. I’m not sure how that would work.

Inserting a comma after a method is probably a simple fix though.

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 24, 2023

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the tarball bundle task on this PR at c8c1362. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 24, 2023

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/147442/artifacts?artifactName=tgz&fileId=15F4A14CB62D24A33ECCB099BECF33B7FD716C86403F150625454CDA0F90E6EC02&fileName=/typescript-5.0.0-insiders.20230224.tgz"
}
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.0.0-pr-52899-9".;

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 23, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the diff-based user code test suite (tsserver) on this PR at 2fff618. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 23, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the perf test suite on this PR at 2fff618. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 23, 2023

Copy link
Copy Markdown
Contributor

Hey Gabriela Araujo Britto (@gabritto), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/155616/artifacts?artifactName=tgz&fileId=F301120EC23B827A689FD11AD89A0FC38467A1E720AE3EF3FB7F7ED9074D307102&fileName=/typescript-5.2.0-insiders.20230623.tgz"
}
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.2.0-pr-52899-20".;

Comment threadsrc/services/completions.ts Outdated
if (source === CompletionSource.ObjectLiteralMemberWithComma && contextToken) {
const changes = textChanges.ChangeTracker.with(
{ host, formatContext, preferences },
tracker => tracker.insertText(sourceFile, contextToken.end,","));

Choose a reason for hiding this comment

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

Suggested change
tracker=>tracker.insertText(sourceFile,contextToken.end,","));
tracker=>tracker.insertText(sourceFile,contextToken.end,","),
);

Comment threadsrc/services/completions.ts Outdated

if (completionKind === CompletionKind.ObjectPropertyDeclaration && contextToken &&
findPrecedingToken(contextToken.pos, sourceFile, contextToken)?.kind !== SyntaxKind.CommaToken &&
(isMethodDeclaration(contextToken.parent.parent) || isSpreadAssignment(contextToken.parent) || findAncestor(contextToken.parent, (node: Node) => isPropertyAssignment(node))?.getLastToken() === contextToken ||

@DanielRosenwasserDaniel Rosenwasser (DanielRosenwasser)Jun 23, 2023

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.

  1. You don't need to annotate the type of node, it'll be inferred (edit: but you can also just write isPropertyAssignment directly.
  2. Feed through the sourceFile when using Node methods so that they don't have to walk back up the tree.
Suggested change
(isMethodDeclaration(contextToken.parent.parent)||isSpreadAssignment(contextToken.parent)||findAncestor(contextToken.parent,(node: Node)=>isPropertyAssignment(node))?.getLastToken()===contextToken||
(isMethodDeclaration(contextToken.parent.parent)||isSpreadAssignment(contextToken.parent)||findAncestor(contextToken.parent,node=>isPropertyAssignment(node))?.getLastToken(sourceFile)===contextToken||

Choose a reason for hiding this comment

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

I'd also rather you just broke this into 2 nested ifs, where it looks like

if(completionKind===CompletionKind.ObjectPropertyDeclaration&&contextToken&&findPrecedingToken(contextToken.pos,sourceFile,contextToken)?.kind!==SyntaxKind.CommaToken){if(isMethodDeclaration(contextToken.parent.parent)||isSpreadAssignment(contextToken.parent)||
...){source=CompletionSource.ObjectLiteralMemberWithComma;hasAction=true;}}

Choose a reason for hiding this comment

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

Wait, you don't need node => isPropertyAssignment, just use isPropertyAssignment directly.

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the user test suite comparing main and refs/pull/52899/merge:

Everything looks good!

Comment threadsrc/services/completions.ts Outdated
hasAction = true;
}

if (completionKind === CompletionKind.ObjectPropertyDeclaration && contextToken &&

Choose a reason for hiding this comment

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

Leave a comment above here with an example of what you're trying to capture.

Comment threadsrc/services/completions.ts Outdated
else {
if (isObjectLiteralExpression(contextToken.parent.parent) &&
(isSpreadAssignment(contextToken.parent) || isShorthandPropertyAssignment(contextToken.parent) &&
(getLineAndCharacterOfPosition(contextToken.getSourceFile(), contextToken.getEnd()).line !== getLineAndCharacterOfPosition(contextToken.getSourceFile(), position).line))) {

Choose a reason for hiding this comment

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

Pass through the sourceFile here too and reuse the same sourceFile

Comment threadsrc/services/completions.ts Outdated
(getLineAndCharacterOfPosition(contextToken.getSourceFile(), contextToken.getEnd()).line !== getLineAndCharacterOfPosition(contextToken.getSourceFile(), position).line))) {
return contextToken.parent.parent;
}
const ancestorNode = findAncestor(parent, (node: Node) => isPropertyAssignment(node));

@DanielRosenwasserDaniel Rosenwasser (DanielRosenwasser)Jun 23, 2023

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.

Suggested change
constancestorNode=findAncestor(parent,(node: Node)=>isPropertyAssignment(node));
constancestorNode=findAncestor(parent,isPropertyAssignment);

Comment threadsrc/services/completions.ts Outdated
if (parent.parent && parent.parent.parent && isMethodDeclaration(parent.parent) && isObjectLiteralExpression(parent.parent.parent)) {
return parent.parent.parent;
}
const ancestorNode = findAncestor(parent, (node: Node) => isPropertyAssignment(node));

Choose a reason for hiding this comment

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

Suggested change
constancestorNode=findAncestor(parent,(node: Node)=>isPropertyAssignment(node));
constancestorNode=findAncestor(parent,isPropertyAssignment);

Comment threadsrc/services/completions.ts Outdated
return parent.parent.parent;
}
const ancestorNode = findAncestor(parent, (node: Node) => isPropertyAssignment(node));
if (contextToken.kind !== SyntaxKind.ColonToken && ancestorNode && ancestorNode.getLastToken() === contextToken &&

Choose a reason for hiding this comment

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

Suggested change
if(contextToken.kind!==SyntaxKind.ColonToken&&ancestorNode&&ancestorNode.getLastToken()===contextToken&&
if(contextToken.kind!==SyntaxKind.ColonToken&&ancestorNode?.getLastToken()===contextToken&&

Comment threadsrc/services/completions.ts Outdated
}
break;
default:
if (parent.parent && parent.parent.parent && isMethodDeclaration(parent.parent) && isObjectLiteralExpression(parent.parent.parent)) {

Choose a reason for hiding this comment

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

Suggested change
if(parent.parent&&parent.parent.parent&&isMethodDeclaration(parent.parent)&&isObjectLiteralExpression(parent.parent.parent)){
if(parent.parent?.parent&&isMethodDeclaration(parent.parent)&&isObjectLiteralExpression(parent.parent.parent)){

Comment threadsrc/services/completions.ts Outdated
return contextToken.parent.parent;
}
const ancestorNode = findAncestor(parent, (node: Node) => isPropertyAssignment(node));
if (ancestorNode && ancestorNode.getLastToken() === contextToken && isObjectLiteralExpression(ancestorNode.parent)) {

Choose a reason for hiding this comment

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

Suggested change
if(ancestorNode&&ancestorNode.getLastToken()===contextToken&&isObjectLiteralExpression(ancestorNode.parent)){
if(ancestorNode?.getLastToken()===contextToken&&isObjectLiteralExpression(ancestorNode.parent)){

Comment threadsrc/services/completions.ts Outdated

if (completionKind === CompletionKind.ObjectPropertyDeclaration && contextToken &&
findPrecedingToken(contextToken.pos, sourceFile, contextToken)?.kind !== SyntaxKind.CommaToken &&
(isMethodDeclaration(contextToken.parent.parent) || isSpreadAssignment(contextToken.parent) || findAncestor(contextToken.parent, (node: Node) => isPropertyAssignment(node))?.getLastToken() === contextToken ||

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 think the spread assignment case should be handled the same as the property assignment case, because the spread assignment can also contain any expression, like this:

constv: I={
...a.b.c.d}

so I think the condition here should be something like:
findAncestor(contextToken.parent, node => isPropertyAssignment(node) || isSpreadAssignment(node))?.getLastToken()

Comment threadsrc/services/completions.ts Outdated
(getLineAndCharacterOfPosition(contextToken.getSourceFile(), contextToken.getEnd()).line !== getLineAndCharacterOfPosition(contextToken.getSourceFile(), position).line))) {
return contextToken.parent.parent;
}
const ancestorNode = findAncestor(parent, (node: Node) => isPropertyAssignment(node));

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.

Same as my comment above regarding spread assignments, I think you can handle them together with property assignment:
const ancestorNode = findAncestor(parent, node => isPropertyAssignment(node) || isSpreadAssignment(node));

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto)
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - main..52899
Metricmain52899DeltaBestWorstp-value
Angular - node (v18.10.0, x64)
Memory used366,629k (± 0.01%)366,614k (± 0.01%)~366,562k366,663kp=0.574 n=6
Parse Time3.41s (± 0.58%)3.42s (± 0.44%)~3.39s3.43sp=0.871 n=6
Bind Time1.12s (± 0.67%)1.11s (± 0.68%)~1.10s1.12sp=0.062 n=6
Check Time8.88s (± 0.46%)8.86s (± 0.47%)~8.81s8.91sp=0.421 n=6
Emit Time7.54s (± 0.85%)7.49s (± 0.55%)~7.45s7.55sp=0.092 n=6
Total Time20.95s (± 0.38%)20.87s (± 0.36%)~20.80s20.99sp=0.173 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used191,919k (± 1.22%)190,967k (± 0.01%)~190,937k191,006kp=0.810 n=6
Parse Time1.50s (± 0.98%)1.49s (± 1.82%)~1.45s1.53sp=0.515 n=6
Bind Time0.78s (± 1.05%)0.77s (± 0.72%)-0.01s (- 1.50%)0.76s0.77sp=0.025 n=6
Check Time9.50s (± 0.74%)9.45s (± 0.38%)~9.39s9.49sp=0.053 n=6
Emit Time2.78s (± 1.61%)2.74s (± 0.81%)~2.72s2.78sp=0.196 n=6
Total Time14.56s (± 0.70%)14.44s (± 0.13%)-0.12s (- 0.84%)14.42s14.47sp=0.016 n=6
Monaco - node (v18.10.0, x64)
Memory used346,796k (± 0.01%)346,815k (± 0.00%)~346,784k346,837kp=0.298 n=6
Parse Time2.60s (± 0.78%)2.60s (± 1.03%)~2.56s2.63sp=0.809 n=6
Bind Time1.01s (± 0.97%)1.01s (± 0.81%)~1.00s1.02sp=0.862 n=6
Check Time7.20s (± 0.57%)7.17s (± 0.29%)~7.14s7.20sp=0.142 n=6
Emit Time4.27s (± 1.59%)4.26s (± 0.53%)~4.22s4.28sp=0.373 n=6
Total Time15.07s (± 0.65%)15.04s (± 0.34%)~14.94s15.07sp=0.872 n=6
TFS - node (v18.10.0, x64)
Memory used300,855k (± 0.00%)300,872k (± 0.00%)+17k (+ 0.01%)300,862k300,885kp=0.010 n=6
Parse Time2.06s (± 1.49%)2.08s (± 0.61%)~2.06s2.09sp=0.359 n=6
Bind Time1.14s (± 0.66%)1.13s (± 1.48%)~1.11s1.16sp=0.155 n=6
Check Time6.64s (± 0.72%)6.63s (± 0.56%)~6.58s6.68sp=0.808 n=6
Emit Time3.86s (± 1.02%)3.87s (± 0.95%)~3.81s3.90sp=0.809 n=6
Total Time13.71s (± 0.50%)13.71s (± 0.39%)~13.62s13.77sp=0.936 n=6
material-ui - node (v18.10.0, x64)
Memory used482,348k (± 0.02%)482,325k (± 0.01%)~482,273k482,389kp=0.810 n=6
Parse Time3.12s (± 0.56%)3.12s (± 0.60%)~3.09s3.14sp=0.935 n=6
Bind Time0.92s (± 1.15%)0.91s (± 1.08%)~0.90s0.93sp=0.547 n=6
Check Time16.96s (± 0.97%)16.90s (± 0.43%)~16.77s16.96sp=0.810 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time21.00s (± 0.79%)20.93s (± 0.39%)~20.77s20.98sp=1.000 n=6
xstate - node (v18.10.0, x64)
Memory used564,208k (± 0.02%)564,226k (± 0.03%)~564,067k564,468kp=1.000 n=6
Parse Time3.83s (± 0.56%)3.83s (± 0.49%)~3.81s3.86sp=0.870 n=6
Bind Time1.64s (± 1.02%)1.64s (± 0.32%)~1.63s1.64sp=0.367 n=6
Check Time2.80s (± 0.73%)2.81s (± 0.53%)~2.79s2.83sp=0.195 n=6
Emit Time0.08s (± 0.00%)0.08s (± 0.00%)~0.08s0.08sp=1.000 n=6
Total Time8.36s (± 0.45%)8.37s (± 0.29%)~8.36s8.42sp=0.683 n=6
Angular - node (v16.17.1, x64)
Memory used366,012k (± 0.00%)365,984k (± 0.01%)~365,917k366,027kp=0.470 n=6
Parse Time3.57s (± 0.23%)3.59s (± 0.70%)~3.56s3.63sp=0.190 n=6
Bind Time1.19s (± 0.69%)1.18s (± 0.64%)~1.17s1.19sp=0.120 n=6
Check Time9.64s (± 0.23%)9.62s (± 0.23%)~9.59s9.64sp=0.124 n=6
Emit Time8.00s (± 0.98%)7.93s (± 0.51%)~7.89s7.99sp=0.109 n=6
Total Time22.40s (± 0.46%)22.32s (± 0.28%)~22.25s22.41sp=0.229 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used192,769k (± 0.03%)192,779k (± 0.05%)~192,660k192,912kp=0.575 n=6
Parse Time1.59s (± 0.97%)1.58s (± 0.87%)~1.56s1.60sp=0.351 n=6
Bind Time0.82s (± 1.09%)0.82s (± 0.63%)~0.81s0.82sp=0.541 n=6
Check Time10.12s (± 0.38%)10.10s (± 0.60%)~10.04s10.17sp=0.629 n=6
Emit Time3.04s (± 1.60%)3.03s (± 1.43%)~2.99s3.11sp=1.000 n=6
Total Time15.58s (± 0.46%)15.53s (± 0.52%)~15.43s15.61sp=0.423 n=6
Monaco - node (v16.17.1, x64)
Memory used346,063k (± 0.00%)346,070k (± 0.00%)~346,057k346,085kp=0.630 n=6
Parse Time2.73s (± 0.38%)2.72s (± 0.71%)~2.69s2.74sp=0.192 n=6
Bind Time1.09s (± 1.35%)1.09s (± 0.58%)~1.08s1.10sp=0.787 n=6
Check Time7.89s (± 0.15%)7.86s (± 0.50%)~7.80s7.91sp=0.126 n=6
Emit Time4.50s (± 0.92%)4.47s (± 0.90%)~4.43s4.54sp=0.288 n=6
Total Time16.22s (± 0.36%)16.14s (± 0.42%)~16.04s16.22sp=0.077 n=6
TFS - node (v16.17.1, x64)
Memory used300,222k (± 0.01%)300,221k (± 0.00%)~300,203k300,235kp=0.630 n=6
Parse Time2.17s (± 0.54%)2.16s (± 0.48%)~2.15s2.17sp=0.056 n=6
Bind Time1.24s (± 0.97%)1.24s (± 1.39%)~1.22s1.27sp=0.806 n=6
Check Time7.31s (± 0.53%)7.29s (± 0.42%)~7.24s7.33sp=0.573 n=6
Emit Time4.34s (± 0.65%)4.33s (± 0.35%)~4.30s4.34sp=0.515 n=6
Total Time15.06s (± 0.25%)15.02s (± 0.32%)~14.97s15.10sp=0.092 n=6
material-ui - node (v16.17.1, x64)
Memory used481,561k (± 0.02%)481,622k (± 0.01%)~481,564k481,667kp=0.128 n=6
Parse Time3.26s (± 0.74%)3.26s (± 0.36%)~3.24s3.27sp=0.934 n=6
Bind Time0.95s (± 0.79%)0.95s (± 1.03%)~0.94s0.97sp=0.858 n=6
Check Time17.97s (± 0.48%)17.92s (± 0.52%)~17.79s18.06sp=0.521 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.18s (± 0.48%)22.13s (± 0.44%)~21.99s22.27sp=0.378 n=6
xstate - node (v16.17.1, x64)
Memory used561,690k (± 0.01%)561,751k (± 0.02%)~561,646k561,886kp=0.378 n=6
Parse Time4.01s (± 0.26%)4.00s (± 0.34%)~3.98s4.02sp=0.254 n=6
Bind Time1.74s (± 0.59%)1.73s (± 0.52%)~1.72s1.74sp=0.273 n=6
Check Time3.06s (± 0.40%)3.05s (± 0.45%)~3.04s3.08sp=0.186 n=6
Emit Time0.09s (± 0.00%)0.09s (± 4.45%)~0.09s0.10sp=0.405 n=6
Total Time8.90s (± 0.23%)8.88s (± 0.29%)~8.85s8.92sp=0.092 n=6
Angular - node (v14.21.3, x64)
Memory used360,043k (± 0.01%)360,070k (± 0.02%)~359,970k360,131kp=0.471 n=6
Parse Time3.67s (± 0.84%)3.67s (± 0.22%)~3.65s3.67sp=0.505 n=6
Bind Time1.22s (± 0.33%)1.22s (± 0.42%)~1.21s1.22sp=0.114 n=6
Check Time10.07s (± 0.15%)10.06s (± 0.23%)~10.03s10.09sp=0.452 n=6
Emit Time8.39s (± 0.67%)8.34s (± 0.74%)~8.24s8.42sp=0.199 n=6
Total Time23.34s (± 0.35%)23.28s (± 0.28%)~23.16s23.35sp=0.225 n=6
Compiler-Unions - node (v14.21.3, x64)
Memory used188,144k (± 0.01%)188,125k (± 0.01%)~188,093k188,153kp=0.128 n=6
Parse Time1.63s (± 0.34%)1.61s (± 0.52%)~1.61s1.63sp=0.052 n=6
Bind Time0.85s (± 1.05%)0.84s (± 0.48%)~0.84s0.85sp=0.086 n=6
Check Time10.25s (± 0.89%)10.28s (± 0.26%)~10.23s10.31sp=1.000 n=6
Emit Time3.13s (± 0.92%)3.14s (± 1.33%)~3.10s3.22sp=0.935 n=6
Total Time15.85s (± 0.73%)15.88s (± 0.40%)~15.80s15.99sp=0.689 n=6
Monaco - node (v14.21.3, x64)
Memory used341,182k (± 0.01%)341,184k (± 0.01%)~341,167k341,210kp=0.575 n=6
Parse Time2.82s (± 1.01%)2.80s (± 0.59%)~2.78s2.83sp=0.368 n=6
Bind Time1.12s (± 1.43%)1.10s (± 1.24%)~1.08s1.12sp=0.122 n=6
Check Time8.22s (± 0.34%)8.18s (± 0.34%)-0.04s (- 0.49%)8.13s8.20sp=0.029 n=6
Emit Time4.72s (± 0.92%)4.67s (± 0.72%)~4.63s4.71sp=0.107 n=6
Total Time16.88s (± 0.33%)16.76s (± 0.34%)-0.12s (- 0.70%)16.68s16.81sp=0.016 n=6
TFS - node (v14.21.3, x64)
Memory used295,307k (± 0.00%)295,305k (± 0.00%)~295,299k295,316kp=0.198 n=6
Parse Time2.40s (± 0.89%)2.37s (± 0.32%)-0.03s (- 1.25%)2.36s2.38sp=0.007 n=6
Bind Time1.07s (± 0.38%)1.06s (± 0.71%)~1.05s1.07sp=0.100 n=6
Check Time7.63s (± 0.56%)7.63s (± 0.49%)~7.57s7.67sp=1.000 n=6
Emit Time4.32s (± 0.79%)4.27s (± 0.48%)-0.05s (- 1.12%)4.25s4.31sp=0.019 n=6
Total Time15.42s (± 0.48%)15.33s (± 0.35%)~15.27s15.42sp=0.065 n=6
material-ui - node (v14.21.3, x64)
Memory used477,107k (± 0.00%)477,080k (± 0.01%)~477,023k477,122kp=0.377 n=6
Parse Time3.36s (± 0.64%)3.33s (± 0.31%)~3.32s3.35sp=0.073 n=6
Bind Time1.00s (± 0.54%)1.00s (± 0.00%)~1.00s1.00sp=0.071 n=6
Check Time18.94s (± 0.52%)18.97s (± 0.33%)~18.91s19.06sp=0.748 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time23.30s (± 0.41%)23.30s (± 0.23%)~23.25s23.39sp=0.810 n=6
xstate - node (v14.21.3, x64)
Memory used550,716k (± 0.00%)550,717k (± 0.00%)~550,688k550,738kp=1.000 n=6
Parse Time4.25s (± 0.29%)4.22s (± 0.45%)-0.03s (- 0.59%)4.20s4.24sp=0.026 n=6
Bind Time1.68s (± 0.61%)1.67s (± 0.79%)~1.65s1.69sp=0.134 n=6
Check Time3.15s (± 0.56%)3.14s (± 0.37%)~3.12s3.15sp=0.411 n=6
Emit Time0.09s (± 4.45%)0.09s (± 4.45%)~0.09s0.10sp=1.000 n=6
Total Time9.17s (± 0.31%)9.11s (± 0.22%)-0.06s (- 0.62%)9.09s9.14sp=0.006 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.21.3, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.21.3, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.21.3, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.21.3, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.21.3, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.21.3, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.21.3, x64)
BenchmarkNameIterations
Current528996
Baselinemain6

TSServer

Comparison Report - main..52899
Metricmain52899DeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,564ms (± 0.31%)2,543ms (± 0.31%)-21ms (- 0.83%)2,536ms2,554msp=0.010 n=6
Req 2 - geterr5,367ms (± 0.66%)5,339ms (± 0.44%)~5,318ms5,373msp=0.297 n=6
Req 3 - references339ms (± 0.43%)340ms (± 1.17%)~336ms346msp=0.935 n=6
Req 4 - navto287ms (± 0.28%)286ms (± 0.36%)~285ms288msp=0.112 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo84ms (± 1.50%)82ms (± 3.56%)~78ms85msp=0.285 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,674ms (± 1.58%)2,636ms (± 0.93%)~2,601ms2,664msp=0.128 n=6
Req 2 - geterr4,102ms (± 0.53%)4,083ms (± 0.53%)~4,056ms4,112msp=0.295 n=6
Req 3 - references348ms (± 0.94%)348ms (± 0.47%)~346ms350msp=0.871 n=6
Req 4 - navto288ms (± 0.28%)287ms (± 0.64%)~286ms290msp=0.235 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo65ms (± 3.83%)72ms (± 3.38%)+7ms (+10.54%)70ms76msp=0.004 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen3,092ms (± 0.32%)3,082ms (± 0.51%)~3,063ms3,105msp=0.173 n=6
Req 2 - geterr1,555ms (± 1.28%)1,575ms (± 1.08%)~1,549ms1,592msp=0.128 n=6
Req 3 - references114ms (± 1.44%)114ms (± 1.83%)~111ms116msp=0.743 n=6
Req 4 - navto368ms (± 0.14%)367ms (± 0.17%)~366ms368msp=0.091 n=6
Req 5 - completionInfo count2,870 (± 0.00%)2,870 (± 0.00%)~2,8702,870p=1.000 n=6
Req 5 - completionInfo372ms (± 1.99%)378ms (± 1.80%)~369ms387msp=0.109 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,658ms (± 0.60%)2,634ms (± 0.71%)-24ms (- 0.92%)2,602ms2,655msp=0.025 n=6
Req 2 - geterr6,032ms (± 0.25%)6,011ms (± 0.13%)-21ms (- 0.35%)6,003ms6,024msp=0.015 n=6
Req 3 - references353ms (± 0.79%)354ms (± 0.40%)~352ms356msp=0.686 n=6
Req 4 - navto287ms (± 0.72%)287ms (± 1.87%)~281ms294msp=0.572 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo92ms (± 1.12%)89ms (± 8.10%)~74ms93msp=0.118 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,846ms (± 0.63%)2,840ms (± 0.70%)~2,825ms2,868msp=0.630 n=6
Req 2 - geterr4,688ms (± 0.39%)4,664ms (± 0.23%)-25ms (- 0.52%)4,652ms4,679msp=0.045 n=6
Req 3 - references364ms (± 0.40%)362ms (± 0.77%)~359ms367msp=0.250 n=6
Req 4 - navto284ms (± 1.28%)283ms (± 0.66%)~281ms286msp=0.466 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo68ms (± 1.52%)75ms (± 1.08%)+8ms (+11.33%)74ms76msp=0.004 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen3,254ms (± 0.44%)3,229ms (± 0.27%)-25ms (- 0.76%)3,220ms3,243msp=0.010 n=6
Req 2 - geterr1,727ms (± 0.71%)1,734ms (± 0.90%)~1,712ms1,753msp=0.336 n=6
Req 3 - references123ms (± 1.42%)127ms (± 6.56%)~123ms144msp=0.452 n=6
Req 4 - navto351ms (± 0.29%)350ms (± 0.36%)~348ms352msp=0.065 n=6
Req 5 - completionInfo count2,870 (± 0.00%)2,870 (± 0.00%)~2,8702,870p=1.000 n=6
Req 5 - completionInfo415ms (± 1.56%)414ms (± 1.07%)~406ms418msp=0.572 n=6
Compiler-UnionsTSServer - node (v14.21.3, x64)
Req 1 - updateOpen2,808ms (± 0.33%)2,792ms (± 0.64%)~2,776ms2,823msp=0.109 n=6
Req 2 - geterr6,238ms (± 1.30%)6,175ms (± 0.38%)~6,147ms6,205msp=0.076 n=6
Req 3 - references364ms (± 1.07%)362ms (± 1.02%)~358ms369msp=0.224 n=6
Req 4 - navto293ms (± 0.50%)291ms (± 0.34%)-2ms (- 0.57%)290ms293msp=0.046 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo102ms (± 4.25%)104ms (± 0.78%)~103ms105msp=0.065 n=6
CompilerTSServer - node (v14.21.3, x64)
Req 1 - updateOpen2,991ms (± 0.38%)2,967ms (± 0.68%)-23ms (- 0.77%)2,941ms3,000msp=0.045 n=6
Req 2 - geterr4,561ms (± 0.72%)4,569ms (± 1.52%)~4,492ms4,698msp=0.575 n=6
Req 3 - references377ms (± 0.66%)375ms (± 0.69%)~370ms378msp=0.140 n=6
Req 4 - navto299ms (± 0.39%)297ms (± 0.27%)-2ms (- 0.61%)296ms298msp=0.016 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo76ms (± 1.36%)79ms (± 8.45%)~76ms93msp=0.063 n=6
xstateTSServer - node (v14.21.3, x64)
Req 1 - updateOpen3,501ms (± 0.64%)3,465ms (± 0.70%)-37ms (- 1.05%)3,429ms3,486msp=0.031 n=6
Req 2 - geterr1,831ms (± 0.57%)1,824ms (± 0.39%)~1,814ms1,832msp=0.423 n=6
Req 3 - references145ms (± 7.17%)139ms (± 6.89%)~132ms158msp=0.225 n=6
Req 4 - navto397ms (± 1.16%)401ms (± 1.72%)~393ms411msp=0.335 n=6
Req 5 - completionInfo count2,870 (± 0.00%)2,870 (± 0.00%)~2,8702,870p=1.000 n=6
Req 5 - completionInfo438ms (± 1.69%)434ms (± 1.54%)~423ms443msp=0.261 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.21.3, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.21.3, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.21.3, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.21.3, x64)
BenchmarkNameIterations
Current528996
Baselinemain6

Startup

Comparison Report - main..52899
Metricmain52899DeltaBestWorstp-value
tsc-startup - node (v16.17.1, x64)
Execution time142.46ms (± 0.21%)142.53ms (± 0.20%)+0.07ms (+ 0.05%)141.86ms148.11msp=0.001 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time221.68ms (± 0.18%)221.55ms (± 0.18%)-0.13ms (- 0.06%)220.62ms231.43msp=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time223.18ms (± 0.17%)223.09ms (± 0.15%)-0.09ms (- 0.04%)222.23ms226.29msp=0.003 n=600
typescript-startup - node (v16.17.1, x64)
Execution time204.98ms (± 0.18%)205.04ms (± 0.17%)+0.06ms (+ 0.03%)204.29ms210.51msp=0.049 n=600
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
BenchmarkNameIterations
Current528996
Baselinemain6

Developer Information:

Download Benchmark

@DanielRosenwasser

Copy link
Copy Markdown
Member

You should really be using ObjectLiteralElementLike as a guide for what you need to expect for preceding nodes:

exporttypeObjectLiteralElementLike=PropertyAssignment|ShorthandPropertyAssignment|SpreadAssignment|MethodDeclaration|AccessorDeclaration;

But I've noticed you don't provide the comma for accessors.

interfaceSomeType{first: number;second: number}exportletx: SomeType={getfirst(){return42}/**/}

@navya9singh

Copy link
Copy Markdown
MemberAuthor

You should really be using ObjectLiteralElementLike as a guide for what you need to expect for preceding nodes:

exporttypeObjectLiteralElementLike=PropertyAssignment|ShorthandPropertyAssignment|SpreadAssignment|MethodDeclaration|AccessorDeclaration;

But I've noticed you don't provide the comma for accessors.

interfaceSomeType{first: number;second: number}exportletx: SomeType={getfirst(){return42}/**/}

Yeah, I've added a test for that now.

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the top-repos suite comparing main and refs/pull/52899/merge:

Something interesting changed - please have a look.

Details

⚠️ Old server errors ⚠️

Timed out after 600000 ms
Timed out after 600000 ms

Repos no longer reporting the error

Comment threadsrc/services/completions.ts Outdated
Comment threadsrc/services/completions.ts Outdated
Comment threadsrc/services/completions.ts Outdated
Comment threadsrc/services/completions.ts Outdated
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

Archived in project

Development

Successfully merging this pull request may close these issues.

Should provide object member completions when missing commas; also should insert missing commas

7 participants

@navya9singh@andrewbranch@typescript-bot@gabritto@jakebailey@DanielRosenwasser@sandersn