rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.
https://rescript-lang.org/docs/gentype/latest/introduction
MIT License
757 stars 44 forks source link

`Text` or `Error` module is not used properly #583

Closed tsnobip closed 12 months ago

tsnobip commented 2 years ago
// inside file `Styles.res`
module Text = {
  let foo = "foo"
}

produces the following JS:

var $$Text = {
  foo: "foo"
};

exports.$$Text = $$Text;

But GenType doesn't seem to know about the name mangling and produces this:

// @ts-ignore: Implicit any on import
import * as StylesBS__Es6Import from './Styles.mjs';
const StylesBS: any = StylesBS__Es6Import;

export const Text_foo: string = StylesBS.Text.mono;

export const Text: {
  foo: string; 
} = StylesBS.Text

Which inevitably produces an error

`StylesBS.Text` is undefined.

The same thing happens if you name your module Error.

edit: this seems to happen for all the words from rescript keyword list.

wokalski commented 2 years ago

I love genType but this issue has bitten us on so many occasions, it's super painful. Maybe we can find some time to contribute a fix.

ryyppy commented 12 months ago

This repository is being archived. If you feel like the issue still relevant, please re-create it in the compiler repo. Thanks!