DefinitelyTyped/types/babel-plugin-macros/babel-plugin-macros-tests.ts
Billy Kwok 5018a8e150 add types for babel-plugin-macros (#39151)
* add types for babel-plugin-macros

* rename babel-plugin-macros-test.ts to babel-plugin-macros-tests.ts

* add paths in tsconfig.json

* remove patch version from version string

* remove unnecessary generics

* fix import module name and minimum TypeScript version

* update minimum TypeScript version to 2.9
2019-10-16 11:44:50 -07:00

15 lines
400 B
TypeScript

import { createMacro, MacroError } from 'babel-plugin-macros';
const macro = createMacro(
({ references, state, babel }) => {
references.forEach(() => {});
references.default.forEach(() => {});
state.abc = 123;
babel.parse("console.log('Hello world!')");
throw new MacroError('testing');
},
{ configName: 'test' },
);
macro() === 'Hello world!';