[jscodeshift] Fix TSC errors and DTS lints

This commit is contained in:
Brie
2019-01-28 22:25:23 -08:00
parent 5a750fd73f
commit f3e79d7ac8
3 changed files with 5 additions and 5 deletions
@@ -26,7 +26,7 @@
* var a = c => c;
*
*/
import { Transform, MemberExpression, FunctionExpression } from "jscodeshift";
import { Transform, MemberExpression, FunctionExpression, ArrowFunctionExpression } from "jscodeshift";
const transform: Transform = (file, api) => {
const j = api.jscodeshift;
@@ -42,7 +42,7 @@ const transform: Transform = (file, api) => {
// Grab the function body. Since we looked for the CallExpression originally, the "callee.object" would refer
// to the FunctionExpression that's being called .bind(this) on. We need the body of that function
// to transform into an ArrowFunctionExpression.
let body = object.body;
let body: ArrowFunctionExpression['body'] = object.body;
// We can get a bit clever here. If we have a function that consists of a single return statement in it's body,
// we can transform it to the more compact arrowFunctionExpression (a, b) => a + b, vs (a + b) => { return a + b }
let useExpression = false;
@@ -25,7 +25,7 @@
* return a + b + this.c;
* }
*/
import { Transform } from "jscodeshift";
import { Transform, ArrowFunctionExpression } from "jscodeshift";
const transform: Transform = (file, api) => {
const j = api.jscodeshift;
@@ -36,7 +36,7 @@ const transform: Transform = (file, api) => {
// using the arrowFunctionExpression. As that could potentially have some unintended consequences.
.filter(p => j(p).find(j.ThisExpression).size() === 0)
.replaceWith(p => {
let body = p.value.body;
let body: ArrowFunctionExpression['body'] = p.value.body;
// We can get a bit clever here. If we have a function that consists of a single return statement in it's body,
// we can transform it to the more compact arrowFunctionExpression (a, b) => a + b, vs (a + b) => { return a + b }
let useExpression = false;
@@ -135,7 +135,7 @@ const transform: Transform = (file, api) => {
return j.functionExpression(
p.value.id,
p.value.params,
j.blockStatement([decl].concat((p.value.body as BlockStatement).body))
j.blockStatement([decl].concat(p.value.body.body))
);
}
).toSource();