packages/babel-types/src/comments/addComment.ts
raw| 1 | import addComments from "./addComments"; |
| 2 | import type * as t from ".."; |
| 3 | |
| 4 | /** |
| 5 | * Add comment of certain type to a node. |
| 6 | */ |
| 7 | export default function addComment<T extends t.Node>( |
| 8 | node: T, |
| 9 | type: t.CommentTypeShorthand, |
| 10 | content: string, |
| 11 | line?: boolean, |
| 12 | ): T { |
| 13 | return addComments(node, type, [ |
| 14 | { |
| 15 | type: line ? "CommentLine" : "CommentBlock", |
| 16 | value: content, |
| 17 | } as t.Comment, |
| 18 | ]); |
| 19 | } |