Last active
March 19, 2021 21:43
-
-
Save Jarred-Sumner/75fb937a8bd5235bba1e4d7a984ddeac to your computer and use it in GitHub Desktop.
Add import * as React from "react"; to the top of every TypeScript file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const addImports = require("jscodeshift-add-imports"); | |
module.exports = function (fileInfo, api, options) { | |
const j = api.jscodeshift; | |
const code = fileInfo.source; | |
const root = j(code); | |
addImports(root, [j.template.statement`import * as React from 'react'`]); | |
return root.toSource(); | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jscodeshift --transform=codemod.js --extensions=.tsx,.jsx ./**/*.tsx --parser tsx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment