Skip to content

Commit fad2aa0

Browse files
Copilotjakebailey
andauthored
Fix panic in inlay hints for tuple types (#2040)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jakebailey <[email protected]>
1 parent ed6e33f commit fad2aa0

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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/ls/lsutil"
8+
"github.com/microsoft/typescript-go/internal/testutil"
9+
)
10+
11+
func TestInlayHintsTupleTypeCrash(t *testing.T) {
12+
t.Parallel()
13+
14+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
15+
const content = `function iterateTuples(tuples: [string][]): void {
16+
tuples.forEach((l) => {})
17+
}`
18+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
19+
f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{
20+
IncludeInlayFunctionParameterTypeHints: true,
21+
})
22+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// === Inlay Hints ===
2+
tuples.forEach((l) => {})
3+
^
4+
{
5+
"position": {
6+
"line": 1,
7+
"character": 19
8+
},
9+
"label": [
10+
{
11+
"value": ": "
12+
},
13+
{
14+
"value": "["
15+
},
16+
{
17+
"value": "string"
18+
},
19+
{
20+
"value": "]"
21+
}
22+
],
23+
"kind": 1,
24+
"paddingLeft": true
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--- old.inlayHintsTupleTypeCrash.baseline
2+
+++ new.inlayHintsTupleTypeCrash.baseline
3+
@@= skipped --1, +0 lines =@@
4+
+// === Inlay Hints ===
5+
+ tuples.forEach((l) => {})
6+
+ ^
7+
+{
8+
+ "label": [
9+
+ {
10+
+ "value": ": "
11+
+ },
12+
+ {
13+
+ "value": "["
14+
+ },
15+
+ {
16+
+ "value": "string"
17+
+ },
18+
+ {
19+
+ "value": "]"
20+
+ }
21+
+ ],
22+
+ "kind": 1,
23+
+ "paddingLeft": true
24+
+}

0 commit comments

Comments
 (0)