comment.d.ts 1.3 KB

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