mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
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:
committed by
Armando Aguirre
parent
8c7f656341
commit
d4916b921d
@@ -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!')");
|
||||
|
||||
Vendored
+11
-20
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user