diff --git a/internal/fourslash/tests/quickInfoAmbientModule_test.go b/internal/fourslash/tests/quickInfoAmbientModule_test.go new file mode 100644 index 00000000000..f015460ee68 --- /dev/null +++ b/internal/fourslash/tests/quickInfoAmbientModule_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestQuickInfoAmbientModule(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare module "*.css"/*1*/;` + + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyQuickInfoAt(t, "1", `module "*.css"`, "") +} diff --git a/internal/ls/hover.go b/internal/ls/hover.go index 291d6fa1506..6ae1babe0b4 100644 --- a/internal/ls/hover.go +++ b/internal/ls/hover.go @@ -365,7 +365,8 @@ func getQuickInfoAndDeclarationAtLocation(c *checker.Checker, symbol *ast.Symbol } if flags&ast.SymbolFlagsModule != 0 { writeNewLine() - b.WriteString(core.IfElse(symbol.ValueDeclaration != nil && ast.IsSourceFile(symbol.ValueDeclaration), "module ", "namespace ")) + isModule := symbol.ValueDeclaration != nil && (ast.IsSourceFile(symbol.ValueDeclaration) || ast.IsAmbientModule(symbol.ValueDeclaration)) + b.WriteString(core.IfElse(isModule, "module ", "namespace ")) b.WriteString(c.SymbolToStringEx(symbol, container, ast.SymbolFlagsNone, symbolFormatFlags)) setDeclaration(core.Find(symbol.Declarations, ast.IsModuleDeclaration)) }