compat.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import type { ModuleName, Target, TargetVersion } from "./shared";
  2. type StringOrRegExp = string | RegExp;
  3. type Modules = StringOrRegExp | readonly StringOrRegExp[];
  4. type BrowserslistQuery = string | ReadonlyArray<string>;
  5. type Environments = {
  6. [target in Target]?: string | number;
  7. };
  8. type Targets = Environments & {
  9. browsers?: Environments | BrowserslistQuery,
  10. esmodules?: boolean,
  11. };
  12. type CompatOptions = {
  13. /** entry / module / namespace / an array of them, by default - all `core-js` modules */
  14. modules?: Modules,
  15. /** a blacklist, entry / module / namespace / an array of them, by default - empty list */
  16. exclude?: Modules,
  17. /** optional browserslist or core-js-compat format query */
  18. targets?: Targets | BrowserslistQuery,
  19. /** used `core-js` version, by default the latest */
  20. version?: string,
  21. /** inverse of the result, shows modules that are NOT required for the target environment */
  22. inverse?: boolean,
  23. /**
  24. * @deprecated use `modules` instead
  25. */
  26. filter?: Modules
  27. };
  28. type CompatOutput = {
  29. /** array of required modules */
  30. list: ModuleName[],
  31. /** object with targets for each module */
  32. targets: {
  33. [module: ModuleName]: {
  34. [target in Target]?: TargetVersion
  35. }
  36. }
  37. }
  38. declare function compat(options?: CompatOptions): CompatOutput;
  39. export = compat;