Thread Entered - Create Libdef

I use Flow to help the author of the JS project. If I want to provide a libdef file in addition to it, I need to create it manually or I can execute some magic command so that I don’t know what lib def will generate for me?

Something like $ flow-typed doyourmagic would be nice.

EDIT:

Found this overflowing

What says:

There are two things:

If the file belongs to you (i.e. it is not a third-party lib inside node_modules or such), you can create a * .js.flow file next to it that documents its export.

If the file does not belong to you (i.e. a third-party library inside node_modules or such), then you can create a libdef file inside flow-typed / name-of-library.js

For .js.flow files, you write the definitions as follows:

 // @flow declare module.exports: { ... } 

For libdef files, you write the following definitions:

 declare module "my-third-party-library" { declare module.exports: {... } } 

On my question, I get to the camp "belongs to you."

I guess I'm confused:

  • How do I write these files.
  • How / where I publish these files to package it for reference to another project.

Also, why do I need to create a .js.flow file manually? Could this be magical? Perhaps this intention continues, but has not yet been realized.

+5
source share
1 answer

I found a good guide that shows how to pack stream code along with compiled code. So:

  • You do not need to write your own libdefs, you can use the entire source code of the stream. If you want a definition with type declarations only, you can look at flow gen-flow-files , although this is still experimental and may fail.
  • You can pack them as *.js.flow , and the stream checker will automatically select them when you import your library.
+2
source

Source: https://habr.com/ru/post/1266372/


All Articles