Codeshift Declared Arrow Expression to Function Declaration Transform
jscodeshift transform to convert arrow function expressions, assigned to variable declarations, into traditional function declarations
Before:
;; ; addfoo, bar;
After:
;; addfoo, bar;
This transform applies to any arrow expression that is assigned to a variable (var
/let
/const
) at the point of declaration.
Usage
$ npm i -DE codeshift-transform-declared-arrow-to-func-dec$ jscodeshift -t node_modules/codeshift-transform-declared-arrow-to-func-dec/dist/index.js some-source-file.js
Examples
Implied/implicit return
Before:
;
After:
Async functions
Before:
;
After:
Exported functions
Before:
;
After:
Complex functions
Before:
;
After:
Unsupported functionality
The following examples are not supported by the transform (but might be introduced in the next major version).
Deferred function assignments
; ; f = x + 1; // will not be transformed!
this
Rebinding