Closed kaminskypavel closed 6 years ago
Thanks!
Seems to be failing for standard (non-arrow) functions with zero arguments. Here is an example test case that fails:
it.only('should return "() => any" for functions without arguments', () => {
expect(
$_$twiz.typeName(function() {
return new Date(0);
}),
).toBe('() => any');
});
This will return (0: any) => any
instead of the expected () => any)
.
A few more cases that produce invalid code:
([{a}]) => 0
results in ({a}Array: any) => any
({a:b}) => 0
results in (a: bObject: {a: b: any}) => any
({a: [b, c]}) => 0
results in ({a: bArray: any,c] }: any) => any
(a = Math.max(0, 2)) => 0
results in (a: any,2: any) => any
@urish super interesting that it would pass the test with the suite, but fail with it.only. anyhow, solved.
fixing #20 for the following cases
fn = () => a fn = (a = 5) => a fn = ({a}) => a fn = ([a]) => a fn = (...args) => args[0]