Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
31 changes: 31 additions & 0 deletions internal/fourslash/tests/manual/inlayHintsCrashReparsed_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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 TestInlayHintsCrashReparsed(t *testing.T) {
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
func TestInlayHintsCrashReparsed(t *testing.T) {
func TestInlayHintsOnModuleExportsWithFunctionExpression(t *testing.T) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 28b2b1b.

t.Parallel()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `
// @allowJs: true
// @checkJs: true

// @Filename: /a.js
module.exports = function () {
return 1;
};
`

f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{InlayHints: lsutil.InlayHintsPreferences{
IncludeInlayFunctionLikeReturnTypeHints: true,
IncludeInlayFunctionParameterTypeHints: true,
}})
}
2 changes: 1 addition & 1 deletion internal/ls/inlay_hints.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type inlayHintState struct {
}

func (s *inlayHintState) visit(node *ast.Node) bool {
if node == nil || node.End()-node.Pos() == 0 {
if node == nil || node.End()-node.Pos() == 0 || node.Flags&ast.NodeFlagsReparsed != 0 {
return false
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// === Inlay Hints ===
module.exports = function () {
^
{
"position": {
"line": 0,
"character": 28
},
"label": [
{
"value": ": "
},
{
"value": "number"
}
],
"kind": 1,
"paddingLeft": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- old.inlayHintsCrashReparsed.baseline
+++ new.inlayHintsCrashReparsed.baseline
Copy link
Member

Choose a reason for hiding this comment

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

Why is this getting a diff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in commit 28b2b1b. The .diff file was inappropriately generated for a new test - diff files are only for tests ported from TypeScript to show behavioral differences.

@@= skipped --1, +0 lines =@@
+// === Inlay Hints ===
+module.exports = function () {
+ ^
+{
+ "label": [
+ {
+ "value": ": "
+ },
+ {
+ "value": "number"
+ }
+ ],
+ "kind": 1,
+ "paddingLeft": true
+}