darklang / rescript-tea

The Elm Architecture for Rescript
Other
119 stars 9 forks source link

generate interface files #10

Closed OceanOak closed 2 years ago

OceanOak commented 2 years ago

Generating interface files (.resi ) for all implementation files (.res)

OceanOak commented 2 years ago

Changes made

tea_json.resi

1

type rec t<'a> = Map.Make(String).t<'a> Map.Make didn't work inside .resi file used Belt.Map.String instead in both .resi and res file to match.

2

Used Js.Json.parseExn(string) instead of Web.Json.parseExn(string) because of The value parseExn can't be found in Web.Json error

3

removed some values from ObjectDict because of this error Expected declaration In module Decoder.ObjectDict: The value `empty' is required but not provided.

example on what was removed

    let empty: t<'a>
    let is_empty: t<'a> => bool
    let mem: (key, t<'a>) => bool

tea_svg.resi

let switch: (~key: string=?, ~unique: string=?, Vdom.properties<'a>, list<Vdom.t<'a>>) => Vdom.t<'a>

switch is a reserved keyword error. Changed it to:

let \"switch": (~key: string=?, ~unique: string=?, Vdom.properties<'a>, list<Vdom.t<'a>>) => Vdom.t<'a>

tea.res Didn't generate .resi file for tea.res, it only containes modules.

All the rest of the files were generated without any errors.

pbiggar commented 2 years ago

Changes made

tea_json.resi

1

type rec t<'a> = Map.Make(String).t<'a> Map.Make didn't work inside .resi file used Belt.Map.String instead in both .resi and res file to match.

This is a change we should make anyway, so this is fine.

2

Used Js.Json.parseExn(string) instead of Web.Json.parseExn(string) because of The value parseExn can't be found in Web.Json error

The issue here is that the new file Web_json.resi only has definitions for things defined in Web_json.res. However, Web_json.res also includes Js.Json. So we accidentally hide the Js.Json stuff by adding the .resi. I think the best approach here would be to remove Web_json.resi for now, as it will break things for other users.

This change is fine though.

3

removed some values from ObjectDict because of this error Expected declaration In module Decoder.ObjectDict: The value `empty' is required but not provided.

example on what was removed

    let empty: t<'a>
    let is_empty: t<'a> => bool
    let mem: (key, t<'a>) => bool

tea_svg.resi

let switch: (~key: string=?, ~unique: string=?, Vdom.properties<'a>, list<Vdom.t<'a>>) => Vdom.t<'a>

switch is a reserved keyword error. Changed it to:

let \"switch": (~key: string=?, ~unique: string=?, Vdom.properties<'a>, list<Vdom.t<'a>>) => Vdom.t<'a>

Can you rename this function switch' instead?

pbiggar commented 2 years ago

Great, thanks!