This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Support non-ES5 target in tsconfig #83
Labels
Comments
Thank you for your feedback! Can you some concrete code examples that crash TypeWiz? I experimented with a simple destructuring variables, params and default values, and it seems like they all work correctly. Here are the test cases that worked for me (you can paste them in it('should handle variable destructuring', () => {
const input = `
const test = x => x;
let { foo } = { foo: 'bar' };
test(foo);
`;
expect(typeWiz(input)).toBe(`
const test = (x: string) => x;
let { foo } = { foo: 'bar' };
test(foo);
`);
});
it('should handle default function parameters', () => {
const input = `
function f(n, x = 'world') {};
f(1, 'hello');
`;
expect(typeWiz(input)).toBe(`
function f(n: number, x = 'world') {};
f(1, 'hello');
`);
});
it('should handle function parameter destructuring', () => {
const input = `
function f({a, b}, c) {};
f({a: 1, b: 2}, 5);
`;
expect(typeWiz(input)).toBe(`
function f({a, b}: { a: number, b: number }, c: number) {};
f({a: 1, b: 2}, 5);
`);
}); |
Sorry, I should have mentioned it's destructured params with defaults. Here you go:
|
Thanks, I managed to reproduce this and write a failing test case for it: it('issue #83: invalid code produced for parameter destructuring with default values', () => {
const input = `
function greet({ who = "" }) {
return 'Hello, ' + who;
}
greet('world');
`;
expect(typeWiz(input)).toBe(`
function greet({ who = "" }: { who: string }) {
return 'Hello, ' + who;
}
greet('world');
`);
}); |
urish
added a commit
that referenced
this issue
Nov 28, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Thanks for your work on this project.
This is a feature request for support for tsconfig targets beyond ES5. I experimentally found that typewiz crashes on targets above ES5 (on things like destructuring params and whatnot).
I'd love to apply this to a large and newly migrated TS codebase that is targeting ES2017 (and more codebases beyond this one). However, downgrading the codebase to ES5 would be a large undertaking (and a backward step at that).
The text was updated successfully, but these errors were encountered: