diff --git a/.chronus/changes/fix-dup-doc-2024-2-1-20-28-15.md b/.chronus/changes/fix-dup-doc-2024-2-1-20-28-15.md new file mode 100644 index 0000000000..1c45bcfe4c --- /dev/null +++ b/.chronus/changes/fix-dup-doc-2024-2-1-20-28-15.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@typespec/compiler" +--- + +[IDE] Fix type documentation shown twice when hovering symbols or in completion details. diff --git a/packages/compiler/src/lib/decorators.ts b/packages/compiler/src/lib/decorators.ts index 29866cd033..eba631960a 100644 --- a/packages/compiler/src/lib/decorators.ts +++ b/packages/compiler/src/lib/decorators.ts @@ -91,7 +91,7 @@ export interface DocData { /** * How was the doc set. - * - `@doc` means the `@doc` decorator was used + * - `decorator` means the `@doc` decorator was used * - `comment` means it was set from a `/** comment * /` */ source: "decorator" | "comment"; diff --git a/packages/compiler/src/server/type-details.ts b/packages/compiler/src/server/type-details.ts index 0d9c43fdde..67876a374e 100644 --- a/packages/compiler/src/server/type-details.ts +++ b/packages/compiler/src/server/type-details.ts @@ -64,8 +64,8 @@ function getSymbolDocumentation(program: Program, symbol: Sym) { // Add @doc(...) API docs const type = symbol.type ?? program.checker.getTypeForNode(symbol.declarations[0]); const apiDocs = getDocData(program, type); - // The doc comment is already included above we don't want to duplicate - if (apiDocs && apiDocs.source === "comment") { + // The doc comment is already included above we don't want to duplicate. Only include if it was specificed via `@doc` + if (apiDocs && apiDocs.source === "decorator") { docs.push(apiDocs.value); }