NumberFour / n4js

Type-Safety of Java & Javascript Flexibility
http://numberfour.github.io/n4js/
38 stars 8 forks source link

Spead with JSX props is not generated correctly #413

Closed qtran-n4 closed 7 years ago

qtran-n4 commented 7 years ago
import * as React from "react"

const baz = {}
const f1 =  <div {...baz} foo qux="tt" tux={5} />
const f2 = <div foo {...baz} qux="tt" tux={5} />
const f3 = <div foo qux="tt" tux={5} {...baz} />

is generated to identical code

f1 = React.createElement('div', Object.assign({}, baz, {
    foo: true,
    qux: "tt",
    tux: 5
}));
f2 = React.createElement('div', Object.assign({}, baz, {
    foo: true,
    qux: "tt",
    tux: 5
}));
f3 = React.createElement('div', Object.assign({}, baz, {
    foo: true,
    qux: "tt",
    tux: 5
}));

which is wrong because the override behavior of properties from left to right is lost.

qtran-n4 commented 7 years ago

@dbo I am currently looking into the bug.