GithubHelp home page GithubHelp logo

aminya / flowgen-package Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 1.0 147 KB

Generate FlowTyped compatible types for all the TypeScript definitions in a package

License: Apache License 2.0

JavaScript 100.00%

flowgen-package's Introduction

Flowgen-package

Generate Flow types for all the TypeScript definitions in a package

CLI

flowgen-package --packageName semver --bundlePath ./semver.js.flow
flowgen-package --packageName semver --bundlePath ./semver.js.flow --packageDir "./node_modules/some_package"
flowgen-package --packageName semver --bundlePath ./semver.js.flow --typesInstallScript "pnpm install --save-dev @types/semver"
Usage: flowgen-package [options]

Options:
  -V, --version                              output the version number
  --packageName <packageName>                The name of the package
  --bundlePath <bundlePath>                  Generate a bundle suitable for FlowTyped at this path
  --typesInstallScript <typesInstallScript>  The install script used to install `@types/packageName`. By default npm install is used
  --packageDir <packageDir>                  If given instead of installing `@types/packageName`, the types for this package are generated
  -h, --help                                 display help for command

JavsScirpt API

const { flowgenPackage } = require("flowgen-package")

flowgenPackage({
  packageName: "semver",
  bundlePath: "./semver.js",
})

For more information and options see the following:

/**
 * @typedef {object} Options
 * @property {string} packageName The name of the package
 * @property {string | undefined} bundlePath Generate a bundle suitable for FlowTyped at this path
 * @property {string | undefined} typesInstallScript The install script used to install `@types/packageName`. By default
 *   npm install is used
 * @property {string | undefined} packageDir If given instead of installing `@types/packageName`, the types for this
 *   package are generated
 */

/**
 * Generate Flow types from @types package
 *
 * @param {Options} options See the above for the documentation of options
 */
async function flowgenPackage(options)

flowgen-package's People

Contributors

aminya avatar

Watchers

 avatar  avatar  avatar

Forkers

projectbarks

flowgen-package's Issues

imports within declare module

flowgen-package looks promising!

I tried using with with @aws-sdk/client-ssm...

The output has import statements nested within declare module. Later in the file, the imported types are actually defined, but I don't think that the import statements are allowed within declare module anymore. For example:

// Generated from @types/@aws-sdk/client-ssm/dist/types/SSM using github.com/aminya/flowgen-package
declare module "@aws-sdk/client-ssm/dist/types/SSM" {
  import type  SSMClient from "@aws-sdk/client-ssm/dist/types/SSMClient"
  import {
    AddTagsToResourceCommandInput,
    AddTagsToResourceCommandOutput,
  } from "./commands/AddTagsToResourceCommand";

//....

declare module "@aws-sdk/client-ssm/dist/types/commands/AddTagsToResourceCommand" {
//...
  declare export type AddTagsToResourceCommandInput = { ... } & AddTagsToResourceRequest;

Do you know if there is a solution to this problem?

Probably the importFromRegex is not capable of matching this multi-line case.

Add License

I was hoping to use this module but I am unable to do so until a license is added.

Would you mind adding one? I would love to contribute back to the library. Ideally MIT so people are able to iterate upon the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.