JSMonk/hegel

Generating type annotations for functions

jarble opened this issue ยท 4 comments

I want to generate some type annotations to a function like this one:

function abs_pow(a,b){
    return Math.abs(Math.pow(a,b));
}

With type annotations, it would look something like this (using TypeScript syntax):

function abs_pow(a:number,b:number):number{
    return Math.abs(Math.pow(a,b));
}

Is it possible to generate these annotations automatically using Hegel, instead of typing them manually?

@jarble currently hagel will infer type (number, number) => number for that function so there is no need to write it manually

There should be some way to generate annotated source code from a program without type annotations: the documentation doesn't explain how to do this, so I don't know if Hegel has this feature yet.

you mean generating .d.ts files? i think that is not implemented yet

Hi @jarble .
Yes, we have a high level of type inference, so you able to skip an annotation of your arguments and return type.
We described it in the section of the documentation.
If you mean by "automatically generating of an annotation" a generating of d.ts file with annotation, then I want to say, that this part of the project currently in development.
I'd a little bit stop working because I'd married :D
But I promise I will come back to the project soon :3