Nav apraksta

index.d.ts 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // based on @types/postcss-load-config@2.0.1
  2. // Type definitions for postcss-load-config 2.1
  3. import Processor from 'postcss/lib/processor';
  4. import { Plugin, ProcessOptions, Transformer } from 'postcss';
  5. import { Options as ConfigOptions } from "lilconfig";
  6. declare function postcssrc(
  7. ctx?: postcssrc.ConfigContext,
  8. path?: string,
  9. options?: ConfigOptions
  10. ): Promise<postcssrc.Result>;
  11. declare namespace postcssrc {
  12. // In the ConfigContext, these three options can be instances of the
  13. // appropriate class, or strings. If they are strings, postcss-load-config will
  14. // require() them and pass the instances along.
  15. export interface ProcessOptionsPreload {
  16. parser?: string | ProcessOptions['parser'];
  17. stringifier?: string | ProcessOptions['stringifier'];
  18. syntax?: string | ProcessOptions['syntax'];
  19. }
  20. // The remaining ProcessOptions, sans the three above.
  21. export type RemainingProcessOptions = Pick<
  22. ProcessOptions,
  23. Exclude<keyof ProcessOptions, keyof ProcessOptionsPreload>
  24. >;
  25. // Additional context options that postcss-load-config understands.
  26. export interface Context {
  27. cwd?: string;
  28. env?: string;
  29. }
  30. // The full shape of the ConfigContext.
  31. export type ConfigContext = Context &
  32. ProcessOptionsPreload &
  33. RemainingProcessOptions;
  34. // Result of postcssrc is a Promise containing the filename plus the options
  35. // and plugins that are ready to pass on to postcss.
  36. export type ResultPlugin = Plugin | Transformer | Processor;
  37. export interface Result {
  38. file: string;
  39. options: ProcessOptions;
  40. plugins: ResultPlugin[];
  41. }
  42. export type ConfigPlugin = Transformer | Plugin | Processor;
  43. export interface Config {
  44. parser?: string | ProcessOptions['parser'] | false;
  45. stringifier?: string | ProcessOptions['stringifier'] | false;
  46. syntax?: string | ProcessOptions['syntax'] | false;
  47. map?: string | false;
  48. from?: string;
  49. to?: string;
  50. plugins?: Array<ConfigPlugin | false> | Record<string, object | false>;
  51. }
  52. export type ConfigFn = (ctx: ConfigContext) => Config | Promise<Config>;
  53. }
  54. export = postcssrc;