Skip to content

Proposal to provide cleaner representation for poly variants #4295

Closed
@Risto-Stevcev

Description

@Risto-Stevcev

One of the pain points of using bucklescript over typescript are the type representations when compiled to js. Having the unboxed option type turns out to be extremely useful both for targeting js (ie: writing libs in bucklescript that can be used in js projects) and ingesting js libs.

The proposal here is provide a cleaner js representation for poly variants or both poly and regular variants. For example:

let a = `foo

becomes

const a = "foo"

and

let b = `bar 123

becomes

const b = { bar: 123 }

This would make it much easier to interact with js libs, making something like [@bs.unwrap] unnecessary. It would also make it easier to write libraries that can be used as both a bucklescript library and a plain js library, because the representations would compile to clean js code without the need for a compatibility module for js with jsConverters that could potentially lead to a really large bundle size.

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