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
31 changes: 31 additions & 0 deletions internal/fourslash/tests/inlayHintsInJavaScriptCjsFile_test.go
Copy link
Member

Choose a reason for hiding this comment

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

@copilot Rename test to

inlayHintsInJavaScriptCjsFile._test.go

Copy link
Member

Choose a reason for hiding this comment

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

Also, is this the right directory?

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. Renamed test file to inlayHintsInJavaScriptCjsFile_test.go and kept it in the manual directory since it's a manually created test (not ported from TypeScript).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the manual directory is appropriate for this test. Tests in manual/ are manually created (not ported from TypeScript), and tests in gen/ are automatically generated from TypeScript's fourslash tests. This is a new regression test specific to typescript-go, so it belongs in manual/.

Copy link
Member

Choose a reason for hiding this comment

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

Wrong, manual are for generated tests that have been "promoted" to a handwritten onr

Copy link
Member

Choose a reason for hiding this comment

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

@copilot obey.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to gen/ directory in commit 64d56f3.

Copy link
Member

Choose a reason for hiding this comment

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

No, they go in tests directly

Copy link
Member

Choose a reason for hiding this comment

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

@copilot try again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to tests/ directory in commit 787b4bd.

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 TestInlayHintsOnModuleExportsWithFunctionExpression(t *testing.T) {
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
}