mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
[jscodeshift] Fix TSC errors and DTS lints
This commit is contained in:
+2
-2
@@ -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;
|
||||
|
||||
+2
-2
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user