Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Generating type annotations for functions #318

Open
jarble opened this issue Dec 4, 2020 · 4 comments
Open

Generating type annotations for functions #318

jarble opened this issue Dec 4, 2020 · 4 comments
Labels
question Further information is requested

Comments

@jarble
Copy link

jarble commented Dec 4, 2020

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?

@thecotne
Copy link
Contributor

thecotne commented Dec 4, 2020

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

@jarble
Copy link
Author

jarble commented Dec 4, 2020

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.

@thecotne
Copy link
Contributor

thecotne commented Dec 4, 2020

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

@JSMonk
Copy link
Owner

JSMonk commented Dec 5, 2020

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

@JSMonk JSMonk added the question Further information is requested label Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants