Rescript-compiler: Typescript declaration files status

Created on 13 Aug 2016  路  5Comments  路  Source: rescript-lang/rescript-compiler

Hi!

I've been playing with the compiler using -bs-gen-tds, for

let sum x y = x + y

currently I get

export var sum: (x : any, y : any) => any ;

It is planned to improve the types anytime soon?

Thanks!
Pablo

stale

Most helpful comment

Is this something that will be improved upon? It would be nice if the .t.ds files have better types. If I want to use bucklescript generated code in typescript, I'm back to adding the types myself, while they are already known...

All 5 comments

can you describe your use case here? the original motivation is typescript requires user to have .d.ts file to get it working, so generating .d.ts will make typescript happy.

We can improve the .d.ts here (at least for primitive type), but the benefit is not clear

I'm looking for our current pain points to try using BS/Reason in our typescript backend, and typescript doesn't have run time type checking. My idea is to have a type checker using a json decoder, so if I have:

{ "id": 1, "name": "foo"}

I would create a decoder in Ocaml with a .d.ts something like this:

type IdName = {
    id: number,
    name: string
}
export var id_name_checker: (json: string) => IdName

It's just an idea, maybe not a good one, and I can find another place where I can get BS in my code base.

Btw thanks for this project

@chenglou Reopened this issue is for tracking generate .t.ds files for Flow. To make it sound, we have to use any a lot, we can preserve primitive types though

Is this something that will be improved upon? It would be nice if the .t.ds files have better types. If I want to use bucklescript generated code in typescript, I'm back to adding the types myself, while they are already known...

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chenglou picture chenglou  路  6Comments

cknitt picture cknitt  路  5Comments

chenglou picture chenglou  路  4Comments

bobzhang picture bobzhang  路  5Comments

bobzhang picture bobzhang  路  5Comments