extract-const-value.d.ts 846 B

1234567891011121314151617181920212223
  1. import type { Module } from '@swc/core';
  2. export declare class NoSuchDeclarationError extends Error {
  3. }
  4. export declare class UnsupportedValueError extends Error {
  5. /** @example `config.runtime[0].value` */
  6. path?: string;
  7. constructor(message: string, paths?: string[]);
  8. }
  9. /**
  10. * Extracts the value of an exported const variable named `exportedName`
  11. * (e.g. "export const config = { runtime: 'experimental-edge' }") from swc's AST.
  12. * The value must be one of (or throws UnsupportedValueError):
  13. * - string
  14. * - boolean
  15. * - number
  16. * - null
  17. * - undefined
  18. * - array containing values listed in this list
  19. * - object containing values listed in this list
  20. *
  21. * Throws NoSuchDeclarationError if the declaration is not found.
  22. */
  23. export declare function extractExportedConstValue(module: Module, exportedName: string): any;