Skip to content

Commit e2eed29

Browse files
authored
Preserve the original parameter-list range when injecting reparsed this parameter (#2976)
1 parent a6220bb commit e2eed29

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
"github.com/microsoft/typescript-go/internal/testutil"
8+
)
9+
10+
func TestDocumentHighlightJSDocThisFunctionExpressionParameter(t *testing.T) {
11+
t.Parallel()
12+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
13+
const content = `// @allowJs: true
14+
// @Filename: /a.js
15+
/**@this{A}*/x=function(/*m*/a){};`
16+
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
17+
defer done()
18+
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "m")
19+
}

internal/parser/reparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node)
470470
newParams[i+1] = param
471471
}
472472

473-
fun.FunctionLikeData().Parameters = p.newNodeList(thisParam.Loc, newParams)
473+
fun.FunctionLikeData().Parameters = p.newNodeList(fun.ParameterList().Loc, newParams)
474474
p.finishMutatedNode(fun)
475475
}
476476
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// === documentHighlights ===
2+
// === /a.js ===
3+
// /**@this{A}*/x=function(/*HIGHLIGHTS*/[|a|]){};

0 commit comments

Comments
 (0)