Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I generate .d.ts typings from Flow code?

Tags:

flowtype

I have enabled Flow on a JavaScript project I am developing. Since I am putting in the effort to providing type annotations, I would really like to generate *.d.ts files so the broader TypeScript community can also have type information.

How can I generate *.d.ts type definition files from Flow-annotated JavaScript?

like image 970
vossad01 Avatar asked Jun 20 '17 14:06

vossad01


People also ask

Are D ts files automatically generated?

d. ts type are automatically created at build time.

Where can I create a D ts file?

d. ts files and put them in the dist/lib folder. You do need a tsconfig. json file in the root of your project, but that should be there for the project to work anyway.

What is D ts file TypeScript?

The "d. ts" file is used to provide typescript type information about an API that's written in JavaScript. The idea is that you're using something like jQuery or underscore, an existing javascript library. You want to consume those from your typescript code.


1 Answers

I searched for the available tools. I found the following.

The first one is the most up to date one. It can convert the whole Flow code to TypeScript. I have used it personally, and it works like a charm.

https://github.com/Khan/flow-to-ts

Other ones:

https://github.com/Kiikurage/babel-plugin-flow-to-typescript

https://github.com/burnnat/flow-to-dts

https://github.com/bcherny/flow-to-typescript

https://github.com/yuya-takeyama/flow2dts

like image 121
Amin Avatar answered Oct 24 '22 22:10

Amin