diff --git a/types/babel-plugin-syntax-jsx/babel-plugin-syntax-jsx-tests.ts b/types/babel-plugin-syntax-jsx/babel-plugin-syntax-jsx-tests.ts new file mode 100644 index 0000000000..4dcb7b4882 --- /dev/null +++ b/types/babel-plugin-syntax-jsx/babel-plugin-syntax-jsx-tests.ts @@ -0,0 +1,10 @@ +import jsx from "babel-plugin-syntax-jsx"; + +// Example taken from the babel plugin handbook: +// https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#-enabling-syntax-in-plugins +export default function myBabelPlugin() { + return { + visitor: {}, + inherits: jsx, + }; +} diff --git a/types/babel-plugin-syntax-jsx/index.d.ts b/types/babel-plugin-syntax-jsx/index.d.ts new file mode 100644 index 0000000000..c7b0ede972 --- /dev/null +++ b/types/babel-plugin-syntax-jsx/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for babel-plugin-syntax-jsx 6.18 +// Project: https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-jsx +// Definitions by: Marvin Hagemeister +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// NB: This export doesn't match the handbook example, where `jsx` is the default export. +// But it does match the runtime behaviour (at least at the time of this writing). For some reason, +// babel-plugin-syntax-jsx/lib/index.js has this line at the bottom: module.exports = exports["default"]; +declare function jsx(): { + manipulateOptions(opts: any, parserOpts: { plugins: string[] }): void; +}; + +export default jsx; diff --git a/types/babel-plugin-syntax-jsx/tsconfig.json b/types/babel-plugin-syntax-jsx/tsconfig.json new file mode 100644 index 0000000000..bb19fbf329 --- /dev/null +++ b/types/babel-plugin-syntax-jsx/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "babel-plugin-syntax-jsx-tests.ts" + ] +} diff --git a/types/babel-plugin-syntax-jsx/tslint.json b/types/babel-plugin-syntax-jsx/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/babel-plugin-syntax-jsx/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }