sweet-core
sweet-core copied to clipboard
Transpilation issues
Here are some issues I encountered when running previously working code through Sweet (babel settings identical):
// PARSING ERRORS:
let k = 'foo';
let a = { [k]: true }
// Missing case in fields: ComputedPropertyName
let { foo: foo } = { bar: 'bar' };
// not implemented yet for: BindingPropertyProperty
let hi = (
/* line-break */
) => {}
// cannot get the val of a delimiter
function baz(x) { return ``; };
// Cannot read property 'startLocation' of undefined
let { bar = Math.random(1) } = { bar: 'bar' };
// Cannot read property 'typeName' of undefined
let str = `${Math.random(1)}`;
// Cannot read property 'typeName' of undefined
[...[]]
// Cannot read property 'type' of null
// INCORRECT TRANSPILATION (transpilation runs but the resulting code isn't right):
let ns = { cls: class tmp {} };
let obj = new ns.cls();
// ends up as `new ns().cls()`, triggering:
// TypeError: ns_5109 is not a constructor in [null]
function fn(a, b = a) {}
// ReferenceError: a is not defined
[...[], x]
// ends up as `[undefined, x]` instead of `[x]`
Edit: added 2 more. Do let me know if you'd prefer a dozen separate issues...
I checked some of these out and a few are fixed. Here's what's still broken:
// PARSING ERRORS:
let hi = (
/* line-break */
) => {}
// Error: not a valid expression
// __=>__ { }
let { bar = Math.random(1) } = { bar: 'bar' };
// Cannot read property 'typeName' of undefined
let str = `${Math.random(1)}`;
// Cannot read property 'typeName' of undefined
// INCORRECT TRANSPILATION (transpilation runs but the resulting code isn't right):
function fn(a, b = a) {}
// compiles to function fn(a_0, b_1 = a) {}
// ReferenceError: a is not defined
[...[], x]
// ends up as `[...[],, x]` evaluating to `[undefined, x]` instead of `[x]`
I think the last one is related to #605.
Great to see it's getting better, thanks for the response! :)