Expose getJSDocCommentsAndTags (#53627)

This commit is contained in:
Gerrit Birkeland
2023-04-24 15:36:41 -07:00
committed by GitHub
parent a177af1cc8
commit a1df8f774f
3 changed files with 63 additions and 1 deletions
+23 -1
View File
@@ -4198,7 +4198,29 @@ export function canHaveJSDoc(node: Node): node is HasJSDoc {
}
}
/** @internal */
/**
* This function checks multiple locations for JSDoc comments that apply to a host node.
* At each location, the whole comment may apply to the node, or only a specific tag in
* the comment. In the first case, location adds the entire {@link JSDoc} object. In the
* second case, it adds the applicable {@link JSDocTag}.
*
* For example, a JSDoc comment before a parameter adds the entire {@link JSDoc}. But a
* `@param` tag on the parent function only adds the {@link JSDocTag} for the `@param`.
*
* ```ts
* /** JSDoc will be returned for `a` *\/
* const a = 0
* /**
* * Entire JSDoc will be returned for `b`
* * @param c JSDocTag will be returned for `c`
* *\/
* function b(/** JSDoc will be returned for `c` *\/ c) {}
* ```
*/
export function getJSDocCommentsAndTags(hostNode: Node): readonly (JSDoc | JSDocTag)[];
/** @internal separate signature so that stripInternal can remove noCache from the public API */
// eslint-disable-next-line @typescript-eslint/unified-signatures
export function getJSDocCommentsAndTags(hostNode: Node, noCache?: boolean): readonly (JSDoc | JSDocTag)[];
export function getJSDocCommentsAndTags(hostNode: Node, noCache?: boolean): readonly (JSDoc | JSDocTag)[] {
let result: (JSDoc | JSDocTag)[] | undefined;
// Pull parameter comments from declaring function as well
+20
View File
@@ -8817,6 +8817,26 @@ declare namespace ts {
parent: ConstructorDeclaration;
name: Identifier;
};
/**
* This function checks multiple locations for JSDoc comments that apply to a host node.
* At each location, the whole comment may apply to the node, or only a specific tag in
* the comment. In the first case, location adds the entire {@link JSDoc} object. In the
* second case, it adds the applicable {@link JSDocTag}.
*
* For example, a JSDoc comment before a parameter adds the entire {@link JSDoc}. But a
* `@param` tag on the parent function only adds the {@link JSDocTag} for the `@param`.
*
* ```ts
* /** JSDoc will be returned for `a` *\/
* const a = 0
* /**
* * Entire JSDoc will be returned for `b`
* * @param c JSDocTag will be returned for `c`
* *\/
* function b(/** JSDoc will be returned for `c` *\/ c) {}
* ```
*/
function getJSDocCommentsAndTags(hostNode: Node): readonly (JSDoc | JSDocTag)[];
/** @deprecated */
function createUnparsedSourceFile(text: string): UnparsedSource;
/** @deprecated */
+20
View File
@@ -4771,6 +4771,26 @@ declare namespace ts {
parent: ConstructorDeclaration;
name: Identifier;
};
/**
* This function checks multiple locations for JSDoc comments that apply to a host node.
* At each location, the whole comment may apply to the node, or only a specific tag in
* the comment. In the first case, location adds the entire {@link JSDoc} object. In the
* second case, it adds the applicable {@link JSDocTag}.
*
* For example, a JSDoc comment before a parameter adds the entire {@link JSDoc}. But a
* `@param` tag on the parent function only adds the {@link JSDocTag} for the `@param`.
*
* ```ts
* /** JSDoc will be returned for `a` *\/
* const a = 0
* /**
* * Entire JSDoc will be returned for `b`
* * @param c JSDocTag will be returned for `c`
* *\/
* function b(/** JSDoc will be returned for `c` *\/ c) {}
* ```
*/
function getJSDocCommentsAndTags(hostNode: Node): readonly (JSDoc | JSDocTag)[];
/** @deprecated */
function createUnparsedSourceFile(text: string): UnparsedSource;
/** @deprecated */