UNPKG

1.12 kBTypeScriptView Raw
1// Type definitions for babel-plugin-macros 2.8
2// Project: https://github.com/kentcdodds/babel-plugin-macros
3// Definitions by: Billy Kwok <https://github.com/billykwok>
4// Jake Runzer <https://github.com/coffee-cup>
5// Ifiok Jr. <https://github.com/ifiokjr>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7// Minimum TypeScript Version: 3.4
8
9import * as Babel from '@babel/core';
10
11export = babelPluginMacros;
12
13declare namespace babelPluginMacros {
14 interface References {
15 [key: string]: Babel.NodePath[];
16 }
17
18 interface Options {
19 configName?: string | undefined;
20 }
21
22 interface MacroParams {
23 references: { default: Babel.NodePath[] } & References;
24 state: Babel.PluginPass;
25 babel: typeof Babel;
26 config?: { [key: string]: any } | undefined;
27 }
28
29 type MacroHandler = (params: MacroParams) => void;
30
31 class MacroError extends Error {}
32
33 function createMacro(handler: MacroHandler, options?: Options): any;
34}
35
36declare function babelPluginMacros(babel: typeof Babel, options: any): Babel.PluginObj;