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 new file mode 100644 index 0000000000..ba5f9ca023 --- /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{}, + }) +}