comment.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import Container from './container.js'
  2. import Node, { NodeProps } from './node.js'
  3. declare namespace Comment {
  4. export interface CommentRaws extends Record<string, unknown> {
  5. /**
  6. * The space symbols before the node.
  7. */
  8. before?: string
  9. /**
  10. * The space symbols between `/*` and the comment’s text.
  11. */
  12. left?: string
  13. /**
  14. * The space symbols between the comment’s text.
  15. */
  16. right?: string
  17. }
  18. export interface CommentProps extends NodeProps {
  19. /** Content of the comment. */
  20. text: string
  21. /** Information used to generate byte-to-byte equal node string as it was in the origin input. */
  22. raws?: CommentRaws
  23. }
  24. // eslint-disable-next-line @typescript-eslint/no-use-before-define
  25. export { Comment_ as default }
  26. }
  27. /**
  28. * Represents a comment between declarations or statements (rule and at-rules).
  29. *
  30. * ```js
  31. * Once (root, { Comment }) {
  32. * let note = new Comment({ text: 'Note: …' })
  33. * root.append(note)
  34. * }
  35. * ```
  36. *
  37. * Comments inside selectors, at-rule parameters, or declaration values
  38. * will be stored in the `raws` properties explained above.
  39. */
  40. declare class Comment_ extends Node {
  41. type: 'comment'
  42. parent: Container | undefined
  43. raws: Comment.CommentRaws
  44. /**
  45. * The comment's text.
  46. */
  47. text: string
  48. constructor(defaults?: Comment.CommentProps)
  49. assign(overrides: object | Comment.CommentProps): this
  50. clone(overrides?: Partial<Comment.CommentProps>): this
  51. cloneBefore(overrides?: Partial<Comment.CommentProps>): this
  52. cloneAfter(overrides?: Partial<Comment.CommentProps>): this
  53. }
  54. declare class Comment extends Comment_ {}
  55. export = Comment