
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
flow-api-translator
Advanced tools
Toolkit for creating Flow and TypeScript compatible libraries from Flow source code.
flow-api-translator
enables creating Flow and TypeScript compatible libraries from Flow source code.
This package provides a toolkit of different translation tools to support a number of different JavaScript based language targets from Flow source code.
An important distinction with this translator and others is this is not intended as a migration tool away from Flow, instead the expectation is the source code will continue to be checked by Flow but this translator provides the ability to seamlessly integrate with external Flow, TypeScript and JavaScript based projects.
Below are some common use cases:
Creating a Flow type definition and runtime files from Flow source code is simple. Just get the source text then pass it to the respective translators:
const sourceFile = await fs.readFile('myFile.js', 'utf8');
await fs.writeFile('output/myFile.js.flow', translate.translateFlowToFlowDef(sourceFile, prettierConfig));
await fs.writeFile('output/myFile.js', translate.translateFlowToJS(sourceFile, prettierConfig));
Further conversion to TypeScript definition files is supported. To do this, get the source text and pass it to the respective translators:
const sourceFile = await fs.readFile('myFile.js', 'utf8');
await fs.writeFile('output/myFile.d.ts', translate.translateFlowToTSDef(sourceFile, prettierConfig));
await fs.writeFile('output/myFile.js', translate.translateFlowToJS(sourceFile, prettierConfig));
Haste module paths are commonly used with Flow libraries. TypeScript does not support this so they needs to be converted back to relative paths first:
const sourceFile = await fs.readFile('myFile.js', 'utf8');
const mappedSourceFile = translate.translateFlowImportsTo(
fileContents,
prettierConfig,
{sourceMapper: ({module}) => path.relative(currentLocation, ModuleMap.getModulePath(module))},
);
await fs.writeFile('output/myFile.js.flow', translate.translateFlowToTSDef(mappedSourceFile, prettierConfig));
await fs.writeFile('output/myFile.js', translate.translateFlowToJS(mappedSourceFile, prettierConfig));
FAQs
Toolkit for creating Flow and TypeScript compatible libraries from Flow source code.
The npm package flow-api-translator receives a total of 23,296 weekly downloads. As such, flow-api-translator popularity was classified as popular.
We found that flow-api-translator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.