Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
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 12,114 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 0 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.