babel-plugin-macros: Export all types and fix References type (#41422)

* update babel-plugin-macros types to match docs

* babel-plugin-macros update version and ts version

* babel-plugin-macros update createMacro and MacroError types

* babel-plugin-macros: revert typescript version to 2.9
This commit is contained in:
Jake Runzer
2020-01-09 11:41:01 -08:00
committed by Armando Aguirre
parent 8c7f656341
commit d4916b921d
2 changed files with 13 additions and 22 deletions
@@ -1,8 +1,8 @@
import { createMacro, MacroError } from 'babel-plugin-macros';
import { createMacro, MacroError, References, Options, MacroParams, MacroHandler } from 'babel-plugin-macros';
const macro = createMacro(
({ references, state, babel }) => {
references.forEach(() => {});
Object.keys(references).forEach(() => {});
references.default.forEach(() => {});
state.abc = 123;
babel.parse("console.log('Hello world!')");
+11 -20
View File
@@ -1,36 +1,27 @@
// Type definitions for babel-plugin-macros 2.6
// Type definitions for babel-plugin-macros 2.8
// Project: https://github.com/kentcdodds/babel-plugin-macros
// Definitions by: Billy Kwok <https://github.com/billykwok>
// Jake Runzer <https://github.com/coffee-cup>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
import * as Babel from '@babel/core';
type References = Babel.NodePath[];
export interface References {
[key: string]: Babel.NodePath[];
}
interface Options {
export interface Options {
configName?: string;
}
interface MacroParams {
references: { default: References } & References;
export interface MacroParams {
references: { default: Babel.NodePath[] } & References;
state: any;
babel: typeof Babel;
}
type MacroHandler = (params: MacroParams) => void;
export type MacroHandler = (params: MacroParams) => void;
declare function babel_plugin_macros(
babel: typeof Babel,
ref: {
require: (path: string) => any;
resolvePath: (src: string, baseDir: string) => any;
},
): Babel.PluginObj;
export class MacroError extends Error {}
declare namespace babel_plugin_macros {
class MacroError extends Error {}
function createMacro(handler: MacroHandler, options?: Options): any;
}
export = babel_plugin_macros;
export function createMacro(handler: MacroHandler, options?: Options): any;