From 031ae5f16144c36cf81d3b5f6c08bc9b1e97d7ed Mon Sep 17 00:00:00 2001 From: James Sheppard Date: Thu, 11 Dec 2025 14:07:41 +0100 Subject: [PATCH 1/2] test: Write test for string property crash --- .../completionsJsdocStringProperty_test.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 internal/fourslash/tests/completionsJsdocStringProperty_test.go diff --git a/internal/fourslash/tests/completionsJsdocStringProperty_test.go b/internal/fourslash/tests/completionsJsdocStringProperty_test.go new file mode 100644 index 0000000000..2c70371ea2 --- /dev/null +++ b/internal/fourslash/tests/completionsJsdocStringProperty_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + . "github.com/microsoft/typescript-go/internal/fourslash/tests/util" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestCompletionsJsdocStringProperty(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + + const content = `/** + * @type {{ + * 'string-property': boolean; + */*$*/ identifierProperty: boolean; + * }} + */ +var someVariable;` + + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "$") + f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ + IsIncomplete: false, + ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ + CommitCharacters: &[]string{}, + EditRange: Ignored, + }, + Items: &fourslash.CompletionsExpectedItems{}, + }) +} From 4f3d47e91937d0e51fee7f3dd8c50762b5d9348b Mon Sep 17 00:00:00 2001 From: James Sheppard Date: Thu, 11 Dec 2025 14:23:49 +0100 Subject: [PATCH 2/2] fix: Expand logic to include type elements in JSDoc --- internal/astnav/tokens.go | 2 +- internal/fourslash/tests/completionsJsdocStringProperty_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/astnav/tokens.go b/internal/astnav/tokens.go index c4fb9ee350..b595ee2f1b 100644 --- a/internal/astnav/tokens.go +++ b/internal/astnav/tokens.go @@ -190,7 +190,7 @@ func getTokenAtPosition( flags := scanner.TokenFlags() if tokenStart <= position && (position < tokenEnd) { if token == ast.KindIdentifier || !ast.IsTokenKind(token) { - if ast.IsJSDocKind(current.Kind) { + if ast.IsJSDocKind(current.Kind) || ast.IsTypeElement(current) { return current } panic(fmt.Sprintf("did not expect %s to have %s in its trivia", current.Kind.String(), token.String())) diff --git a/internal/fourslash/tests/completionsJsdocStringProperty_test.go b/internal/fourslash/tests/completionsJsdocStringProperty_test.go index 2c70371ea2..ba5f9ca023 100644 --- a/internal/fourslash/tests/completionsJsdocStringProperty_test.go +++ b/internal/fourslash/tests/completionsJsdocStringProperty_test.go @@ -26,7 +26,7 @@ var someVariable;` f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{ IsIncomplete: false, ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{ - CommitCharacters: &[]string{}, + CommitCharacters: &[]string{".", ",", ";"}, EditRange: Ignored, }, Items: &fourslash.CompletionsExpectedItems{},