diff --git a/src/compiler/objectConstructors.ts b/src/compiler/objectConstructors.ts index 4e78bd788fd..c1a2a1654c0 100644 --- a/src/compiler/objectConstructors.ts +++ b/src/compiler/objectConstructors.ts @@ -42,6 +42,7 @@ import { UnionOrIntersectionType, UnionType, } from "./_namespaces/ts"; +import { SignatureObjectInternals } from "./signatureObjectInternals"; import { SymbolObjectInternals } from "./symbolObjectInternals"; /** @internal */ @@ -316,11 +317,11 @@ export class SignatureObject implements Signature { } getDocumentationComment(): SymbolDisplayPart[] { - throw new TypeError("Not implemented"); + return SignatureObjectInternals.internals.getDocumentationComment(this); } getJsDocTags(): JSDocTagInfo[] { - throw new TypeError("Not implemented"); + return SignatureObjectInternals.internals.getJsDocTags(this); } } diff --git a/src/compiler/signatureObjectInternals.ts b/src/compiler/signatureObjectInternals.ts new file mode 100644 index 00000000000..296305e73e8 --- /dev/null +++ b/src/compiler/signatureObjectInternals.ts @@ -0,0 +1,16 @@ +import { JSDocTagInfo, Signature, SymbolDisplayPart } from "./types"; + +/** @internal */ +export class SignatureObjectInternals { + static internals = new SignatureObjectInternals(); + + getDocumentationComment(signature: Signature): SymbolDisplayPart[]; + getDocumentationComment(_signature: Signature): SymbolDisplayPart[] { + throw new TypeError("Not implemented."); + } + + getJsDocTags(signature: Signature): JSDocTagInfo[]; + getJsDocTags(_signature: Signature): JSDocTagInfo[] { + throw new TypeError("Not implemented."); + } +} diff --git a/src/services/services.ts b/src/services/services.ts index ba5a3b8d773..b6e643d4476 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2,6 +2,7 @@ import { SignatureObject, SymbolObject, } from "../compiler/objectConstructors"; +import { SignatureObjectInternals } from "../compiler/signatureObjectInternals"; import { SymbolObjectInternals } from "../compiler/symbolObjectInternals"; import { __String, @@ -374,15 +375,20 @@ function ensureSignatureExtraFields(signature: Signature) { return extra; } -SignatureObject.prototype.getDocumentationComment = function (this: Signature): SymbolDisplayPart[] { - const extra = ensureSignatureExtraFields(this); - return extra.documentationComment ??= getDocumentationComment(singleElementArray(this.declaration), this.checker); -}; +class ServicesSignatureObjectInternals extends SignatureObjectInternals { + override getDocumentationComment(signature: Signature): SymbolDisplayPart[] { + const extra = ensureSignatureExtraFields(signature); + return extra.documentationComment ??= getDocumentationComment(singleElementArray(signature.declaration), signature.checker); + } -SignatureObject.prototype.getJsDocTags = function (this: Signature): JSDocTagInfo[] { - const extra = ensureSignatureExtraFields(this); - return extra.jsDocTags ??= getJsDocTagsOfDeclarations(singleElementArray(this.declaration), this.checker); -}; + override getJsDocTags(signature: Signature): JSDocTagInfo[] { + const extra = ensureSignatureExtraFields(signature); + return extra.jsDocTags ??= getJsDocTagsOfDeclarations(singleElementArray(signature.declaration), signature.checker); + } +} + +// Override the internals for signatures +SignatureObjectInternals.internals = new ServicesSignatureObjectInternals(); /** * Returns whether or not the given node has a JSDoc "inheritDoc" tag on it.