版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
2.2 KiB

  1. import { Program, Node, CallExpression, Literal, TemplateLiteral, ObjectExpression, ObjectMethod, ObjectProperty, Function } from '@babel/types';
  2. import { ParserOptions } from '@babel/parser';
  3. declare function babelParse(code: string, lang?: string, options?: ParserOptions): Program;
  4. declare function isCallOf(node: Node | null | undefined, test: string | string[] | ((id: string) => boolean)): node is CallExpression;
  5. declare function checkInvalidScopeReference(node: Node | undefined, method: string, setupBindings: string[]): void;
  6. declare function isStaticExpression(node: Node, options?: Partial<Record<'object' | 'fn' | 'objectMethod' | 'array' | 'unary', boolean> & {
  7. magicComment?: string;
  8. }>): boolean;
  9. declare function isLiteralType(node: Node): node is Literal;
  10. declare function resolveTemplateLiteral(node: TemplateLiteral): string;
  11. declare function resolveLiteral(node: Literal): string | number | boolean | null | RegExp | bigint;
  12. declare function isStaticObjectKey(node: ObjectExpression): boolean;
  13. /**
  14. * @param node must be a static expression, SpreadElement is not supported
  15. */
  16. declare function resolveObjectExpression(node: ObjectExpression): Record<string | number, ObjectMethod | ObjectProperty> | undefined;
  17. declare function resolveObjectKey(node: Node, computed?: boolean, raw?: true): string;
  18. declare function resolveObjectKey(node: Node, computed: boolean | undefined, raw: false): string | number;
  19. declare function walkAST<T = Node>(node: T, options: {
  20. enter?: (this: {
  21. skip: () => void;
  22. remove: () => void;
  23. replace: (node: T) => void;
  24. }, node: T, parent: T, key: string, index: number) => void;
  25. leave?: (this: {
  26. skip: () => void;
  27. remove: () => void;
  28. replace: (node: T) => void;
  29. }, node: T, parent: T, key: string, index: number) => void;
  30. }): T;
  31. declare function isFunctionType(node: Node): node is Function;
  32. declare const TS_NODE_TYPES: string[];
  33. declare function unwrapTSNode(node: Node): Node;
  34. export { TS_NODE_TYPES, babelParse, checkInvalidScopeReference, isCallOf, isFunctionType, isLiteralType, isStaticExpression, isStaticObjectKey, resolveLiteral, resolveObjectExpression, resolveObjectKey, resolveTemplateLiteral, unwrapTSNode, walkAST };