Skip to content

Commit

Permalink
fix(typescript_indexer): add ... to vararg parameters (#5842)
Browse files Browse the repository at this point in the history
  • Loading branch information
schroederc committed Sep 14, 2023
1 parent a1b8f8f commit 608d1cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kythe/typescript/indexer.ts
Expand Up @@ -1791,6 +1791,14 @@ class Visitor {
if (context != null) {
codeParts.push(context);
}
if (ts.isParameter(varDecl) && varDecl.dotDotDotToken) {
codeParts.push({
// TODO: this should probably be TYPE but the current renderer adds an
// unnecessary space after TYPEs
kind: MarkedSourceKind.MODIFIER,
pre_text: '...',
});
}
codeParts.push({
kind: MarkedSourceKind.IDENTIFIER,
pre_text: fmtMarkedSource(this.getIdentifierForMarkedSourceNode(decl)),
Expand Down
1 change: 1 addition & 0 deletions kythe/typescript/kythe.ts
Expand Up @@ -256,6 +256,7 @@ export enum MarkedSourceKind {
LOOKUP_BY_TYPED,
PARAMETER_LOOKUP_BY_TPARAM,
LOOKUP_BY_TPARAM,
MODIFIER,
}


Expand Down
14 changes: 14 additions & 0 deletions kythe/typescript/testdata/marked_source/rendered/function.ts
@@ -0,0 +1,14 @@

//- @myFunction defines/binding MyFunction
//- MyFunction.code/rendered/qualified_name "myFunction"
//- MyFunction.code/rendered/callsite_signature "myFunction(arg)"
//- MyFunction.code/rendered/signature "myFunction(arg: string): number"
function myFunction(arg: string = '0'): number {
return 0;
}

//- @varArgs defines/binding VarArgs
//- VarArgs.code/rendered/qualified_name "varArgs"
//- VarArgs.code/rendered/callsite_signature "varArgs(arg)"
//- VarArgs.code/rendered/signature "varArgs(...arg: any[]): void"
function varArgs(...arg: any[]) {}

0 comments on commit 608d1cb

Please sign in to comment.