Skip to content

Encountered error with { ...(bCheck && obj) } #1642

Open
@qin-tain

Description

@qin-tain

The code works for TypeScript, but it causes errors when used with code generated by TSTL.

const obj = { key: 1 }
const num = Math.random()
const a = 0 // 0, 0.5, 1
const b = { ...(num < a && obj) }

generates

obj = {key = 1}
num = math.random()
a = 0
b = __TS__ObjectAssign({}, num < a and obj)

playground

https://typescripttolua.github.io/play/#code/5.4/MYewdgzgLgBCBGArGBeGBvGBrApgTwC4YBGGAXwChRJYwBXAW1RgFkBDKACwDoAnNsABMQDABQBKKuGgw2zAAwwA9EpjyANGu4BWTcSk0Y8Zpm5nR9JgB5ZMAGR24SceQpA

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions