rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.

Home Page:https://rescript-lang.org/docs/gentype/latest/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

tsnobip opened this issue · comments

// 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.

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.

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