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(52604): Provide Object member completions without comma; insert a comma #52899

Merged
merged 18 commits into from
Jun 27, 2023

Conversation

navya9singh
Copy link
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-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 21, 2023
@navya9singh navya9singh changed the title Fix(52604) Fix(52604): Provide Object member completions without comma; insert a comma Feb 21, 2023
Copy link
Member

@andrewbranch andrewbranch left a comment

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.

src/services/completions.ts Outdated Show resolved Hide resolved
src/services/completions.ts Outdated Show resolved Hide resolved
src/services/completions.ts Outdated Show resolved Hide resolved
@@ -423,6 +425,8 @@ export enum CompletionSource {
ObjectLiteralMethodSnippet = "ObjectLiteralMethodSnippet/",
/** Case completions for switch statements */
SwitchCases = "SwitchCases/",
/** Completions for an Object literal expression */
ObjectLiteralExpression = "ObjectLiteralExpression/",
Copy link
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

@@ -592,6 +592,11 @@ export class ChangeTracker {
this.replaceNode(sourceFile, oldNode, newNode, { suffix });
}

public replacePropertyAssignmentOnSameLine(sourceFile: SourceFile, oldNode: PropertyAssignment, newNode: PropertyAssignment): void {
Copy link
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
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.

if (source === CompletionSource.ObjectLiteralExpression && contextToken) {
const changes = textChanges.ChangeTracker.with(
{ host, formatContext, preferences },
tracker=>tracker.insertText(sourceFile, contextToken.end,","));
Copy link
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
Member

I wonder if this works on the playground 🤔

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 23, 2023

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

Hey @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 on lines 1357 to 1358
if ((contextToken && isPropertyAssignment(contextToken.parent) && findNextToken(contextToken, contextToken?.parent, sourceFile)?.kind !== SyntaxKind.CommaToken &&
completionKind === CompletionKind.ObjectPropertyDeclaration)) {
Copy link
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
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
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:

interface T {
    aaa: string;
    foo(): void;
}

const obj: 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
Copy link
Member

gabritto commented Feb 23, 2023

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:

interface T {
    aaa: string;
    bbb: number;
    foo(): void;
}
const obj: T = {
    foo() {
        
    }
    /**/
}
const obj: T = {
    bbb: 1 * 2
    /**/
}

You get the global completions here instead.

@andrewbranch
Copy link
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
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 24, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 24, 2023

Hey @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/[email protected]".;

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 23, 2023

Heya @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
Copy link
Collaborator

typescript-bot commented Jun 23, 2023

Heya @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
Copy link
Collaborator

typescript-bot commented Jun 23, 2023

Hey @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/[email protected]".;

if (source === CompletionSource.ObjectLiteralMemberWithComma && contextToken) {
const changes = textChanges.ChangeTracker.with(
{ host, formatContext, preferences },
tracker => tracker.insertText(sourceFile, contextToken.end,","));
Copy link
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, ","),
);

@@ -1683,6 +1686,15 @@ function createCompletionEntry(
hasAction = true;
}

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
Member

@DanielRosenwasser DanielRosenwasser Jun 23, 2023

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 ||

Copy link
Member

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;
    }
}

Copy link
Member

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
Collaborator

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

Everything looks good!

@@ -1683,6 +1686,15 @@ function createCompletionEntry(
hasAction = true;
}

if (completionKind === CompletionKind.ObjectPropertyDeclaration && contextToken &&
Copy link
Member

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.

else {
if (isObjectLiteralExpression(contextToken.parent.parent) &&
(isSpreadAssignment(contextToken.parent) || isShorthandPropertyAssignment(contextToken.parent) &&
(getLineAndCharacterOfPosition(contextToken.getSourceFile(), contextToken.getEnd()).line !== getLineAndCharacterOfPosition(contextToken.getSourceFile(), position).line))) {
Copy link
Member

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

(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
Member

@DanielRosenwasser DanielRosenwasser Jun 23, 2023

Choose a reason for hiding this comment

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

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

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));
Copy link
Member

Choose a reason for hiding this comment

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

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

return parent.parent.parent;
}
const ancestorNode = findAncestor(parent, (node: Node) => isPropertyAssignment(node));
if (contextToken.kind !== SyntaxKind.ColonToken && ancestorNode && ancestorNode.getLastToken() === contextToken &&
Copy link
Member

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 &&

}
break;
default:
if (parent.parent && parent.parent.parent && isMethodDeclaration(parent.parent) && isObjectLiteralExpression(parent.parent.parent)) {
Copy link
Member

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)) {

return contextToken.parent.parent;
}
const ancestorNode = findAncestor(parent, (node: Node) => isPropertyAssignment(node));
if (ancestorNode && ancestorNode.getLastToken() === contextToken && isObjectLiteralExpression(ancestorNode.parent)) {
Copy link
Member

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)) {

@@ -1683,6 +1686,15 @@ function createCompletionEntry(
hasAction = true;
}

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
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:

const v: I = {
    ...a.b.c.d
}

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

(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
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
Collaborator

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

Here they are:

Compiler

Comparison Report - main..52899
Metric main 52899 Delta Best Worst p-value
Angular - node (v18.10.0, x64)
Memory used 366,629k (± 0.01%) 366,614k (± 0.01%) ~ 366,562k 366,663k p=0.574 n=6
Parse Time 3.41s (± 0.58%) 3.42s (± 0.44%) ~ 3.39s 3.43s p=0.871 n=6
Bind Time 1.12s (± 0.67%) 1.11s (± 0.68%) ~ 1.10s 1.12s p=0.062 n=6
Check Time 8.88s (± 0.46%) 8.86s (± 0.47%) ~ 8.81s 8.91s p=0.421 n=6
Emit Time 7.54s (± 0.85%) 7.49s (± 0.55%) ~ 7.45s 7.55s p=0.092 n=6
Total Time 20.95s (± 0.38%) 20.87s (± 0.36%) ~ 20.80s 20.99s p=0.173 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used 191,919k (± 1.22%) 190,967k (± 0.01%) ~ 190,937k 191,006k p=0.810 n=6
Parse Time 1.50s (± 0.98%) 1.49s (± 1.82%) ~ 1.45s 1.53s p=0.515 n=6
Bind Time 0.78s (± 1.05%) 0.77s (± 0.72%) -0.01s (- 1.50%) 0.76s 0.77s p=0.025 n=6
Check Time 9.50s (± 0.74%) 9.45s (± 0.38%) ~ 9.39s 9.49s p=0.053 n=6
Emit Time 2.78s (± 1.61%) 2.74s (± 0.81%) ~ 2.72s 2.78s p=0.196 n=6
Total Time 14.56s (± 0.70%) 14.44s (± 0.13%) -0.12s (- 0.84%) 14.42s 14.47s p=0.016 n=6
Monaco - node (v18.10.0, x64)
Memory used 346,796k (± 0.01%) 346,815k (± 0.00%) ~ 346,784k 346,837k p=0.298 n=6
Parse Time 2.60s (± 0.78%) 2.60s (± 1.03%) ~ 2.56s 2.63s p=0.809 n=6
Bind Time 1.01s (± 0.97%) 1.01s (± 0.81%) ~ 1.00s 1.02s p=0.862 n=6
Check Time 7.20s (± 0.57%) 7.17s (± 0.29%) ~ 7.14s 7.20s p=0.142 n=6
Emit Time 4.27s (± 1.59%) 4.26s (± 0.53%) ~ 4.22s 4.28s p=0.373 n=6
Total Time 15.07s (± 0.65%) 15.04s (± 0.34%) ~ 14.94s 15.07s p=0.872 n=6
TFS - node (v18.10.0, x64)
Memory used 300,855k (± 0.00%) 300,872k (± 0.00%) +17k (+ 0.01%) 300,862k 300,885k p=0.010 n=6
Parse Time 2.06s (± 1.49%) 2.08s (± 0.61%) ~ 2.06s 2.09s p=0.359 n=6
Bind Time 1.14s (± 0.66%) 1.13s (± 1.48%) ~ 1.11s 1.16s p=0.155 n=6
Check Time 6.64s (± 0.72%) 6.63s (± 0.56%) ~ 6.58s 6.68s p=0.808 n=6
Emit Time 3.86s (± 1.02%) 3.87s (± 0.95%) ~ 3.81s 3.90s p=0.809 n=6
Total Time 13.71s (± 0.50%) 13.71s (± 0.39%) ~ 13.62s 13.77s p=0.936 n=6
material-ui - node (v18.10.0, x64)
Memory used 482,348k (± 0.02%) 482,325k (± 0.01%) ~ 482,273k 482,389k p=0.810 n=6
Parse Time 3.12s (± 0.56%) 3.12s (± 0.60%) ~ 3.09s 3.14s p=0.935 n=6
Bind Time 0.92s (± 1.15%) 0.91s (± 1.08%) ~ 0.90s 0.93s p=0.547 n=6
Check Time 16.96s (± 0.97%) 16.90s (± 0.43%) ~ 16.77s 16.96s p=0.810 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 21.00s (± 0.79%) 20.93s (± 0.39%) ~ 20.77s 20.98s p=1.000 n=6
xstate - node (v18.10.0, x64)
Memory used 564,208k (± 0.02%) 564,226k (± 0.03%) ~ 564,067k 564,468k p=1.000 n=6
Parse Time 3.83s (± 0.56%) 3.83s (± 0.49%) ~ 3.81s 3.86s p=0.870 n=6
Bind Time 1.64s (± 1.02%) 1.64s (± 0.32%) ~ 1.63s 1.64s p=0.367 n=6
Check Time 2.80s (± 0.73%) 2.81s (± 0.53%) ~ 2.79s 2.83s p=0.195 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 8.36s (± 0.45%) 8.37s (± 0.29%) ~ 8.36s 8.42s p=0.683 n=6
Angular - node (v16.17.1, x64)
Memory used 366,012k (± 0.00%) 365,984k (± 0.01%) ~ 365,917k 366,027k p=0.470 n=6
Parse Time 3.57s (± 0.23%) 3.59s (± 0.70%) ~ 3.56s 3.63s p=0.190 n=6
Bind Time 1.19s (± 0.69%) 1.18s (± 0.64%) ~ 1.17s 1.19s p=0.120 n=6
Check Time 9.64s (± 0.23%) 9.62s (± 0.23%) ~ 9.59s 9.64s p=0.124 n=6
Emit Time 8.00s (± 0.98%) 7.93s (± 0.51%) ~ 7.89s 7.99s p=0.109 n=6
Total Time 22.40s (± 0.46%) 22.32s (± 0.28%) ~ 22.25s 22.41s p=0.229 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,769k (± 0.03%) 192,779k (± 0.05%) ~ 192,660k 192,912k p=0.575 n=6
Parse Time 1.59s (± 0.97%) 1.58s (± 0.87%) ~ 1.56s 1.60s p=0.351 n=6
Bind Time 0.82s (± 1.09%) 0.82s (± 0.63%) ~ 0.81s 0.82s p=0.541 n=6
Check Time 10.12s (± 0.38%) 10.10s (± 0.60%) ~ 10.04s 10.17s p=0.629 n=6
Emit Time 3.04s (± 1.60%) 3.03s (± 1.43%) ~ 2.99s 3.11s p=1.000 n=6
Total Time 15.58s (± 0.46%) 15.53s (± 0.52%) ~ 15.43s 15.61s p=0.423 n=6
Monaco - node (v16.17.1, x64)
Memory used 346,063k (± 0.00%) 346,070k (± 0.00%) ~ 346,057k 346,085k p=0.630 n=6
Parse Time 2.73s (± 0.38%) 2.72s (± 0.71%) ~ 2.69s 2.74s p=0.192 n=6
Bind Time 1.09s (± 1.35%) 1.09s (± 0.58%) ~ 1.08s 1.10s p=0.787 n=6
Check Time 7.89s (± 0.15%) 7.86s (± 0.50%) ~ 7.80s 7.91s p=0.126 n=6
Emit Time 4.50s (± 0.92%) 4.47s (± 0.90%) ~ 4.43s 4.54s p=0.288 n=6
Total Time 16.22s (± 0.36%) 16.14s (± 0.42%) ~ 16.04s 16.22s p=0.077 n=6
TFS - node (v16.17.1, x64)
Memory used 300,222k (± 0.01%) 300,221k (± 0.00%) ~ 300,203k 300,235k p=0.630 n=6
Parse Time 2.17s (± 0.54%) 2.16s (± 0.48%) ~ 2.15s 2.17s p=0.056 n=6
Bind Time 1.24s (± 0.97%) 1.24s (± 1.39%) ~ 1.22s 1.27s p=0.806 n=6
Check Time 7.31s (± 0.53%) 7.29s (± 0.42%) ~ 7.24s 7.33s p=0.573 n=6
Emit Time 4.34s (± 0.65%) 4.33s (± 0.35%) ~ 4.30s 4.34s p=0.515 n=6
Total Time 15.06s (± 0.25%) 15.02s (± 0.32%) ~ 14.97s 15.10s p=0.092 n=6
material-ui - node (v16.17.1, x64)
Memory used 481,561k (± 0.02%) 481,622k (± 0.01%) ~ 481,564k 481,667k p=0.128 n=6
Parse Time 3.26s (± 0.74%) 3.26s (± 0.36%) ~ 3.24s 3.27s p=0.934 n=6
Bind Time 0.95s (± 0.79%) 0.95s (± 1.03%) ~ 0.94s 0.97s p=0.858 n=6
Check Time 17.97s (± 0.48%) 17.92s (± 0.52%) ~ 17.79s 18.06s p=0.521 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.18s (± 0.48%) 22.13s (± 0.44%) ~ 21.99s 22.27s p=0.378 n=6
xstate - node (v16.17.1, x64)
Memory used 561,690k (± 0.01%) 561,751k (± 0.02%) ~ 561,646k 561,886k p=0.378 n=6
Parse Time 4.01s (± 0.26%) 4.00s (± 0.34%) ~ 3.98s 4.02s p=0.254 n=6
Bind Time 1.74s (± 0.59%) 1.73s (± 0.52%) ~ 1.72s 1.74s p=0.273 n=6
Check Time 3.06s (± 0.40%) 3.05s (± 0.45%) ~ 3.04s 3.08s p=0.186 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 4.45%) ~ 0.09s 0.10s p=0.405 n=6
Total Time 8.90s (± 0.23%) 8.88s (± 0.29%) ~ 8.85s 8.92s p=0.092 n=6
Angular - node (v14.21.3, x64)
Memory used 360,043k (± 0.01%) 360,070k (± 0.02%) ~ 359,970k 360,131k p=0.471 n=6
Parse Time 3.67s (± 0.84%) 3.67s (± 0.22%) ~ 3.65s 3.67s p=0.505 n=6
Bind Time 1.22s (± 0.33%) 1.22s (± 0.42%) ~ 1.21s 1.22s p=0.114 n=6
Check Time 10.07s (± 0.15%) 10.06s (± 0.23%) ~ 10.03s 10.09s p=0.452 n=6
Emit Time 8.39s (± 0.67%) 8.34s (± 0.74%) ~ 8.24s 8.42s p=0.199 n=6
Total Time 23.34s (± 0.35%) 23.28s (± 0.28%) ~ 23.16s 23.35s p=0.225 n=6
Compiler-Unions - node (v14.21.3, x64)
Memory used 188,144k (± 0.01%) 188,125k (± 0.01%) ~ 188,093k 188,153k p=0.128 n=6
Parse Time 1.63s (± 0.34%) 1.61s (± 0.52%) ~ 1.61s 1.63s p=0.052 n=6
Bind Time 0.85s (± 1.05%) 0.84s (± 0.48%) ~ 0.84s 0.85s p=0.086 n=6
Check Time 10.25s (± 0.89%) 10.28s (± 0.26%) ~ 10.23s 10.31s p=1.000 n=6
Emit Time 3.13s (± 0.92%) 3.14s (± 1.33%) ~ 3.10s 3.22s p=0.935 n=6
Total Time 15.85s (± 0.73%) 15.88s (± 0.40%) ~ 15.80s 15.99s p=0.689 n=6
Monaco - node (v14.21.3, x64)
Memory used 341,182k (± 0.01%) 341,184k (± 0.01%) ~ 341,167k 341,210k p=0.575 n=6
Parse Time 2.82s (± 1.01%) 2.80s (± 0.59%) ~ 2.78s 2.83s p=0.368 n=6
Bind Time 1.12s (± 1.43%) 1.10s (± 1.24%) ~ 1.08s 1.12s p=0.122 n=6
Check Time 8.22s (± 0.34%) 8.18s (± 0.34%) -0.04s (- 0.49%) 8.13s 8.20s p=0.029 n=6
Emit Time 4.72s (± 0.92%) 4.67s (± 0.72%) ~ 4.63s 4.71s p=0.107 n=6
Total Time 16.88s (± 0.33%) 16.76s (± 0.34%) -0.12s (- 0.70%) 16.68s 16.81s p=0.016 n=6
TFS - node (v14.21.3, x64)
Memory used 295,307k (± 0.00%) 295,305k (± 0.00%) ~ 295,299k 295,316k p=0.198 n=6
Parse Time 2.40s (± 0.89%) 2.37s (± 0.32%) -0.03s (- 1.25%) 2.36s 2.38s p=0.007 n=6
Bind Time 1.07s (± 0.38%) 1.06s (± 0.71%) ~ 1.05s 1.07s p=0.100 n=6
Check Time 7.63s (± 0.56%) 7.63s (± 0.49%) ~ 7.57s 7.67s p=1.000 n=6
Emit Time 4.32s (± 0.79%) 4.27s (± 0.48%) -0.05s (- 1.12%) 4.25s 4.31s p=0.019 n=6
Total Time 15.42s (± 0.48%) 15.33s (± 0.35%) ~ 15.27s 15.42s p=0.065 n=6
material-ui - node (v14.21.3, x64)
Memory used 477,107k (± 0.00%) 477,080k (± 0.01%) ~ 477,023k 477,122k p=0.377 n=6
Parse Time 3.36s (± 0.64%) 3.33s (± 0.31%) ~ 3.32s 3.35s p=0.073 n=6
Bind Time 1.00s (± 0.54%) 1.00s (± 0.00%) ~ 1.00s 1.00s p=0.071 n=6
Check Time 18.94s (± 0.52%) 18.97s (± 0.33%) ~ 18.91s 19.06s p=0.748 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 23.30s (± 0.41%) 23.30s (± 0.23%) ~ 23.25s 23.39s p=0.810 n=6
xstate - node (v14.21.3, x64)
Memory used 550,716k (± 0.00%) 550,717k (± 0.00%) ~ 550,688k 550,738k p=1.000 n=6
Parse Time 4.25s (± 0.29%) 4.22s (± 0.45%) -0.03s (- 0.59%) 4.20s 4.24s p=0.026 n=6
Bind Time 1.68s (± 0.61%) 1.67s (± 0.79%) ~ 1.65s 1.69s p=0.134 n=6
Check Time 3.15s (± 0.56%) 3.14s (± 0.37%) ~ 3.12s 3.15s p=0.411 n=6
Emit Time 0.09s (± 4.45%) 0.09s (± 4.45%) ~ 0.09s 0.10s p=1.000 n=6
Total Time 9.17s (± 0.31%) 9.11s (± 0.22%) -0.06s (- 0.62%) 9.09s 9.14s p=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)
Benchmark Name Iterations
Current 52899 6
Baseline main 6

TSServer

Comparison Report - main..52899
Metric main 52899 Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,564ms (± 0.31%) 2,543ms (± 0.31%) -21ms (- 0.83%) 2,536ms 2,554ms p=0.010 n=6
Req 2 - geterr 5,367ms (± 0.66%) 5,339ms (± 0.44%) ~ 5,318ms 5,373ms p=0.297 n=6
Req 3 - references 339ms (± 0.43%) 340ms (± 1.17%) ~ 336ms 346ms p=0.935 n=6
Req 4 - navto 287ms (± 0.28%) 286ms (± 0.36%) ~ 285ms 288ms p=0.112 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 84ms (± 1.50%) 82ms (± 3.56%) ~ 78ms 85ms p=0.285 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,674ms (± 1.58%) 2,636ms (± 0.93%) ~ 2,601ms 2,664ms p=0.128 n=6
Req 2 - geterr 4,102ms (± 0.53%) 4,083ms (± 0.53%) ~ 4,056ms 4,112ms p=0.295 n=6
Req 3 - references 348ms (± 0.94%) 348ms (± 0.47%) ~ 346ms 350ms p=0.871 n=6
Req 4 - navto 288ms (± 0.28%) 287ms (± 0.64%) ~ 286ms 290ms p=0.235 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 65ms (± 3.83%) 72ms (± 3.38%) +7ms (+10.54%) 70ms 76ms p=0.004 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 3,092ms (± 0.32%) 3,082ms (± 0.51%) ~ 3,063ms 3,105ms p=0.173 n=6
Req 2 - geterr 1,555ms (± 1.28%) 1,575ms (± 1.08%) ~ 1,549ms 1,592ms p=0.128 n=6
Req 3 - references 114ms (± 1.44%) 114ms (± 1.83%) ~ 111ms 116ms p=0.743 n=6
Req 4 - navto 368ms (± 0.14%) 367ms (± 0.17%) ~ 366ms 368ms p=0.091 n=6
Req 5 - completionInfo count 2,870 (± 0.00%) 2,870 (± 0.00%) ~ 2,870 2,870 p=1.000 n=6
Req 5 - completionInfo 372ms (± 1.99%) 378ms (± 1.80%) ~ 369ms 387ms p=0.109 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,658ms (± 0.60%) 2,634ms (± 0.71%) -24ms (- 0.92%) 2,602ms 2,655ms p=0.025 n=6
Req 2 - geterr 6,032ms (± 0.25%) 6,011ms (± 0.13%) -21ms (- 0.35%) 6,003ms 6,024ms p=0.015 n=6
Req 3 - references 353ms (± 0.79%) 354ms (± 0.40%) ~ 352ms 356ms p=0.686 n=6
Req 4 - navto 287ms (± 0.72%) 287ms (± 1.87%) ~ 281ms 294ms p=0.572 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 92ms (± 1.12%) 89ms (± 8.10%) ~ 74ms 93ms p=0.118 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,846ms (± 0.63%) 2,840ms (± 0.70%) ~ 2,825ms 2,868ms p=0.630 n=6
Req 2 - geterr 4,688ms (± 0.39%) 4,664ms (± 0.23%) -25ms (- 0.52%) 4,652ms 4,679ms p=0.045 n=6
Req 3 - references 364ms (± 0.40%) 362ms (± 0.77%) ~ 359ms 367ms p=0.250 n=6
Req 4 - navto 284ms (± 1.28%) 283ms (± 0.66%) ~ 281ms 286ms p=0.466 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 68ms (± 1.52%) 75ms (± 1.08%) +8ms (+11.33%) 74ms 76ms p=0.004 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 3,254ms (± 0.44%) 3,229ms (± 0.27%) -25ms (- 0.76%) 3,220ms 3,243ms p=0.010 n=6
Req 2 - geterr 1,727ms (± 0.71%) 1,734ms (± 0.90%) ~ 1,712ms 1,753ms p=0.336 n=6
Req 3 - references 123ms (± 1.42%) 127ms (± 6.56%) ~ 123ms 144ms p=0.452 n=6
Req 4 - navto 351ms (± 0.29%) 350ms (± 0.36%) ~ 348ms 352ms p=0.065 n=6
Req 5 - completionInfo count 2,870 (± 0.00%) 2,870 (± 0.00%) ~ 2,870 2,870 p=1.000 n=6
Req 5 - completionInfo 415ms (± 1.56%) 414ms (± 1.07%) ~ 406ms 418ms p=0.572 n=6
Compiler-UnionsTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 2,808ms (± 0.33%) 2,792ms (± 0.64%) ~ 2,776ms 2,823ms p=0.109 n=6
Req 2 - geterr 6,238ms (± 1.30%) 6,175ms (± 0.38%) ~ 6,147ms 6,205ms p=0.076 n=6
Req 3 - references 364ms (± 1.07%) 362ms (± 1.02%) ~ 358ms 369ms p=0.224 n=6
Req 4 - navto 293ms (± 0.50%) 291ms (± 0.34%) -2ms (- 0.57%) 290ms 293ms p=0.046 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 102ms (± 4.25%) 104ms (± 0.78%) ~ 103ms 105ms p=0.065 n=6
CompilerTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 2,991ms (± 0.38%) 2,967ms (± 0.68%) -23ms (- 0.77%) 2,941ms 3,000ms p=0.045 n=6
Req 2 - geterr 4,561ms (± 0.72%) 4,569ms (± 1.52%) ~ 4,492ms 4,698ms p=0.575 n=6
Req 3 - references 377ms (± 0.66%) 375ms (± 0.69%) ~ 370ms 378ms p=0.140 n=6
Req 4 - navto 299ms (± 0.39%) 297ms (± 0.27%) -2ms (- 0.61%) 296ms 298ms p=0.016 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 76ms (± 1.36%) 79ms (± 8.45%) ~ 76ms 93ms p=0.063 n=6
xstateTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 3,501ms (± 0.64%) 3,465ms (± 0.70%) -37ms (- 1.05%) 3,429ms 3,486ms p=0.031 n=6
Req 2 - geterr 1,831ms (± 0.57%) 1,824ms (± 0.39%) ~ 1,814ms 1,832ms p=0.423 n=6
Req 3 - references 145ms (± 7.17%) 139ms (± 6.89%) ~ 132ms 158ms p=0.225 n=6
Req 4 - navto 397ms (± 1.16%) 401ms (± 1.72%) ~ 393ms 411ms p=0.335 n=6
Req 5 - completionInfo count 2,870 (± 0.00%) 2,870 (± 0.00%) ~ 2,870 2,870 p=1.000 n=6
Req 5 - completionInfo 438ms (± 1.69%) 434ms (± 1.54%) ~ 423ms 443ms p=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)
Benchmark Name Iterations
Current 52899 6
Baseline main 6

Startup

Comparison Report - main..52899
Metric main 52899 Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 142.46ms (± 0.21%) 142.53ms (± 0.20%) +0.07ms (+ 0.05%) 141.86ms 148.11ms p=0.001 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 221.68ms (± 0.18%) 221.55ms (± 0.18%) -0.13ms (- 0.06%) 220.62ms 231.43ms p=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 223.18ms (± 0.17%) 223.09ms (± 0.15%) -0.09ms (- 0.04%) 222.23ms 226.29ms p=0.003 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 204.98ms (± 0.18%) 205.04ms (± 0.17%) +0.06ms (+ 0.03%) 204.29ms 210.51ms p=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)
Benchmark Name Iterations
Current 52899 6
Baseline main 6

Developer Information:

Download Benchmark

@DanielRosenwasser
Copy link
Member

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

export type ObjectLiteralElementLike
    = PropertyAssignment
    | ShorthandPropertyAssignment
    | SpreadAssignment
    | MethodDeclaration
    | AccessorDeclaration
    ;

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

interface SomeType {
    first: number;
    second: number
}

export let x: SomeType = {
    get first() { return 42 }
    /**/
}

@navya9singh
Copy link
Member Author

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

export type ObjectLiteralElementLike
    = PropertyAssignment
    | ShorthandPropertyAssignment
    | SpreadAssignment
    | MethodDeclaration
    | AccessorDeclaration
    ;

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

interface SomeType {
    first: number;
    second: number
}

export let x: SomeType = {
    get first() { return 42 }
    /**/
}

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

@typescript-bot
Copy link
Collaborator

@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

src/services/completions.ts Outdated Show resolved Hide resolved
src/services/completions.ts Outdated Show resolved Hide resolved
src/services/completions.ts Outdated Show resolved Hide resolved
src/services/completions.ts Outdated Show resolved Hide resolved
@DanielRosenwasser DanielRosenwasser merged commit 13460ae into main Jun 27, 2023
@DanielRosenwasser DanielRosenwasser deleted the fix(52604) branch June 27, 2023 01:06
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
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
6 participants