UNPKG

estree-toolkit

Version:

Traverser, scope tracker, and more tools for working with ESTree AST

27 lines (26 loc) 1.13 kB
import type { Node as _Node, JSXSpreadChild, BaseNode } from 'estree-jsx'; import type { ImportAttribute } from 'estree'; export type Node = _Node | JSXSpreadChild | ImportAttribute; export { BaseNode }; /** * Causes a compiler error if a switch is not exhaustive * or you can say causes a compiler error if all possible switch cases * are not covered * * This function would never get called in reality, if your code is correct */ export declare const assertNever: (x: never) => never; export type NodeMap = { [N in Node as `${N['type']}`]: N; }; export type NodeTypes = keyof NodeMap; export type NodeT<N extends NodeTypes> = NodeMap[N]; export type ParentsOf<N extends Node | Node[]> = { [K in NodeTypes]: N extends NodeMap[K][keyof NodeMap[K]] ? NodeMap[K] : never; }[NodeTypes]; export type PossibleKeysInParent<N extends Node | Node[], P extends Node> = Exclude<{ [K in keyof P]: N extends P[K] ? K : never; }[keyof P], undefined>; export declare const toCamelCase: (input: string) => string; /** Creates a clean object that doesn't have any prototype */ export declare const cleanObj: <T>(obj: T) => T;