How to use flowgen - 6 common examples

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 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
 */
${code}
github Chimeejs / chimee / packages / chimee-kernel-flv.js / flow / modules.js View on Github external
import { compiler } from 'flowgen';
const flowdef = compiler.compileDefinitionFile('../node_modules/flv.js/d.ts/flv.d.ts');
console.log(flowdef);

declare module 'toxic-decorators' {
  declare module.exports: any;
}
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);
  }
};
github flow-typed / flow-typed / cli / src / lib / stubUtils.js View on Github external
if (
        e.message.includes(
          '`declare module` cannot be used inside another `declare module`',
        )
      ) {
        flowgenOutput = prettier.format(code, {
          parser: 'babel-flow',
          singleQuote: true,
          semi: true,
        });
      } else {
        flowgenOutput = format(flowgenTemplate, packageName, code);
      }
    }
  } else if (typescriptTypingsContent) {
    const code = flowgen.compiler.compileDefinitionString(
      typescriptTypingsContent,
    );
    try {
      flowgenOutput = prettier.format(
        format(flowgenTemplate, packageName, code),
        {parser: 'babel-flow', singleQuote: true, semi: true},
      );
    } catch (e) {
      if (
        e.message.includes(
          '`declare module` cannot be used inside another `declare module`',
        )
      ) {
        flowgenOutput = prettier.format(code, {
          parser: 'babel-flow',
          singleQuote: true,
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 2 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages