Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,8 @@ func (n *Node) ElementList() *NodeList {
return n.AsNamedExports().Elements
case KindObjectBindingPattern, KindArrayBindingPattern:
return n.AsBindingPattern().Elements
case KindTupleType:
return n.AsTupleTypeNode().Elements
}

panic("Unhandled case in Node.ElementList: " + n.Kind.String())
Expand Down
22 changes: 22 additions & 0 deletions internal/fourslash/tests/inlayHintsTupleTypeCrash_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/ls/lsutil"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestInlayHintsTupleTypeCrash(t *testing.T) {
t.Parallel()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `function iterateTuples(tuples: [string][]): void {
tuples.forEach((l) => {})
}`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{
IncludeInlayFunctionParameterTypeHints: true,
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// === Inlay Hints ===
tuples.forEach((l) => {})
^
{
"position": {
"line": 1,
"character": 19
},
"label": [
{
"value": ": "
},
{
"value": "["
},
{
"value": "string"
},
{
"value": "]"
}
],
"kind": 1,
"paddingLeft": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- old.inlayHintsTupleTypeCrash.baseline
+++ new.inlayHintsTupleTypeCrash.baseline
@@= skipped --1, +0 lines =@@
+// === Inlay Hints ===
+ tuples.forEach((l) => {})
+ ^
+{
+ "label": [
+ {
+ "value": ": "
+ },
+ {
+ "value": "["
+ },
+ {
+ "value": "string"
+ },
+ {
+ "value": "]"
+ }
+ ],
+ "kind": 1,
+ "paddingLeft": true
+}
Loading