root.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import PreviousMap from './previous-map';
  2. import Container from './container';
  3. import * as postcss from './postcss';
  4. import Result from './result';
  5. import Node from './node';
  6. export default class Root extends Container implements postcss.Root {
  7. /**
  8. * Returns a string representing the node's type. Possible values are
  9. * root, atrule, rule, decl or comment.
  10. */
  11. type: string;
  12. rawCache: {
  13. [key: string]: any;
  14. };
  15. /**
  16. * Represents a CSS file and contains all its parsed nodes.
  17. */
  18. constructor(defaults?: postcss.RootNewProps);
  19. /**
  20. * @param overrides New properties to override in the clone.
  21. * @returns A clone of this node. The node and its (cloned) children will
  22. * have a clean parent and code style properties.
  23. */
  24. clone(overrides?: Object): Root;
  25. toJSON(): postcss.JsonRoot;
  26. /**
  27. * Removes child from the root node, and the parent properties of node and
  28. * its children.
  29. * @param child Child or child's index.
  30. * @returns This root node for chaining.
  31. */
  32. removeChild(child: Node | number): this;
  33. protected normalize(node: Node | string, sample: Node, type?: string): Node[];
  34. protected normalize(props: postcss.AtRuleNewProps | postcss.RuleNewProps | postcss.DeclarationNewProps | postcss.CommentNewProps, sample: Node, type?: string): Node[];
  35. /**
  36. * @returns A Result instance representing the root's CSS.
  37. */
  38. toResult(options?: {
  39. /**
  40. * The path where you'll put the output CSS file. You should always
  41. * set "to" to generate correct source maps.
  42. */
  43. to?: string;
  44. map?: postcss.SourceMapOptions;
  45. }): Result;
  46. /**
  47. * Deprecated. Use Root#removeChild.
  48. */
  49. remove(child?: Node | number): Root;
  50. /**
  51. * Deprecated. Use Root#source.input.map.
  52. */
  53. prevMap(): PreviousMap;
  54. }