-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typescript): process TypeScript files
To support TypeScript, mostly we just needed to use the `typescript` parser plugin when the file being processed is TypeScript. BREAKING CHANGE: This expands the set of file extensions that babel-codemod will look for to include `.ts`, `.tsx`, `.es`, `.es6`, and `.mjs` in addition to `.js` and `.jsx`. Closes #137
- Loading branch information
1 parent
9e44e2e
commit 00ae598
Showing
15 changed files
with
183 additions
and
63 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function union<T>(...sets: Array<Set<T>>) { | ||
return new Set(sets.reduce((result, set) => [...result, ...set], [])); | ||
} | ||
|
||
export const TypeScriptExtensions = new Set(['.ts', '.tsx']); | ||
export const JavaScriptExtensions = new Set([ | ||
'.js', | ||
'.jsx', | ||
'.mjs', | ||
'.es', | ||
'.es6' | ||
]); | ||
export const PluginExtensions = union( | ||
TypeScriptExtensions, | ||
JavaScriptExtensions | ||
); | ||
export const RequireableExtensions = union( | ||
TypeScriptExtensions, | ||
JavaScriptExtensions | ||
); | ||
export const TransformableExtensions = union( | ||
TypeScriptExtensions, | ||
JavaScriptExtensions | ||
); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as Babel from '@babel/core'; | ||
import { NodePath } from '@babel/traverse'; | ||
|
||
export default function(babel: typeof Babel) { | ||
const { types: t } = babel; | ||
|
||
return { | ||
visitor: { | ||
TSAnyKeyword(path: NodePath) { | ||
path.replaceWith(t.tsObjectKeyword()); | ||
} | ||
} | ||
}; | ||
} |
Oops, something went wrong.