mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-13 09:12:52 -05:00
Don't mutate SignatureObject from services
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
src/compiler/signatureObjectInternals.ts
Normal file
16
src/compiler/signatureObjectInternals.ts
Normal file
@@ -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.");
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user