Bogdan Savluk 0058b7fef4
Migrate Babel from Flow to TypeScript (except Babel parser) (#11578)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-11-25 23:09:13 +01:00

24 lines
508 B
TypeScript

import { declare } from "@babel/helper-plugin-utils";
export default declare(api => {
api.assertVersion(7);
return {
name: "syntax-jsx",
manipulateOptions(opts, parserOpts) {
// If the Typescript plugin already ran, it will have decided whether
// or not this is a TSX file.
if (
parserOpts.plugins.some(
p => (Array.isArray(p) ? p[0] : p) === "typescript",
)
) {
return;
}
parserOpts.plugins.push("jsx");
},
};
});