How to use the flowgen.beautify function in flowgen

To help you get started, we’ve selected a few flowgen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zerobias / effector / postinstall.js View on Github external
)
    const name = fileName(packageName)
    //console.log(packageName, name, path)
    const file = await fs.readFile(path, 'utf8')
    const hasHeader =
      file.includes(`declare module '${name}'`) ||
      file.includes(`declare module "${name}"`)
    const template = hasHeader
      ? file
      : `
declare module '${name}' {
  ${file}
};
`
    try {
      const code = flowgen.beautify(
        flowgen.compiler.compileDefinitionString(template),
      )
      await fs.ensureFile(`flow-typed/flowgen/${name}_v${json.version}.js`)
      await fs.writeFile(
        `flow-typed/flowgen/${name}_v${json.version}.js`,
        `/**
 * This is an autogenerated libdef stub for:
 *
 *   '${name}'
 *
 * Fill this stub out by fixing all the errors.
 *
 * Once filled out, we encourage you to share your work with the
 * community by sending a pull request to:
 * https://github.com/flowtype/flow-typed
 */
github ritz078 / transform / pages / api / typescript-to-flow.ts View on Github external
export default (req: NextApiRequest, res: NextApiResponse) => {
  try {
    const result = compiler.compileDefinitionString(req.body);
    res.status(200).send(beautify(result));
  } catch (e) {
    res.status(500).send(e.message);
  }
};

flowgen

Generate flowtype definition files from TypeScript

ISC
Latest version published 1 year ago

Package Health Score

54 / 100
Full package analysis