New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript declaration files status #637

Open
paparga opened this Issue Aug 12, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@paparga
Copy link

paparga commented Aug 12, 2016

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

@bobzhang

This comment has been minimized.

Copy link
Member

bobzhang commented Aug 13, 2016

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

@paparga

This comment has been minimized.

Copy link
Author

paparga commented Aug 13, 2016

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

@paparga paparga closed this Aug 13, 2016

@bobzhang bobzhang reopened this Aug 27, 2016

@bobzhang

This comment has been minimized.

Copy link
Member

bobzhang commented Aug 27, 2016

@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

@tcoopman

This comment has been minimized.

Copy link
Contributor

tcoopman commented Oct 2, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment