
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@esmbly/transformer-flow
Advanced tools
An Esmbly transformer that transforms Flow files to TypeScript
@esmbly/transformer-flowTransform Flow files to TypeScript.
# Using Yarn:
yarn add @esmbly/transformer-flow
# Or, using NPM:
npm install @esmbly/transformer-flow --save
Check out Using the Flow transformer guide for a step-by-step guide on how to get started with @esmbly/transformer-flow and the command-line interface.
Try it out in the Esmbly version of WebAssembly Studio!
The @esmbly/transformer-flow transforms Flow files to TypeScript. In order to use it, make sure you have @esmbly/cli installed .
The following Esmbly configuration will transform all JavaScript files located in the src directory and output TypeScript files to the dist directory.
// esmbly.config.js
const Flow = require('@esmbly/transformer-flow');
module.exports = {
input: ['./src/**/*.js'],
transformers: [
Flow.createTransformer(),
],
output: [
{
format: '.ts',
outDir: 'dist',
rootDir: 'src',
},
],
};
The createTransformer() method accepts an optional configuration object (see the FlowTransformerOptions interface). The following options are possible.
| Option | Description | Type | Default |
|---|---|---|---|
| removeFlowFlags (optional) | Whether or not to remove any // @flow comments | boolean | true |
| customRules (optional) | An object containing any custom rules which should be applied (existing rules can be overridden). Check out the custom-rule example for further details. | CustomRules |
@esmbly/transformer-flow and @esmbly/transformer-wasm.@esmbly/transformer-flow and @esmbly/transformer-wasm.@esmbly/transformer-flow with a custom rule.@esmbly/transformer-flow in the browser using Webpack.| Supported? | Flow | TypeScript | |
|---|---|---|---|
| ✅ | Primitive Types | boolean | number | string | null | undefined | boolean | number | string | null | undefined |
| ✅ | Void | void | undefined |
| ✅ | Literal Types | type Two = 2; | type Two = 2; |
| ✅ | Mixed Types | mixed | unknown |
| ✅ | Any Types | any | any |
| ✅ | Maybe Types | ?type | type | null | undefined |
| ✅ | Function Types | (str: string) => boolean | (str: string) => boolean |
| ❌ | Function Shorthand | (A, B) => C | (a: A, b: B) => C |
| ❌ | Predicate Functions | (a: A, b: B) => C %checks | (a: A, b: B) => C |
| ✅ | Object Types | { foo: boolean } | { foo: boolean } |
| ✅ | Exact object types | {| a: A |} | { a: A } |
| ✅ | Indexers | { [A]: B } | { [a: A]: B } |
| ✅ | Array Types | Array<string>, string[] | Array<string>, string[] |
| ✅ | Tuple Types | type A = [number, boolean] | type A = [number, boolean] |
| ✅ | Class Types | ||
| ✅ | Opaque types | opaque type A = B | type A = B (not expressible) |
| ✅ | Interface Types | ||
| ✅ | Variance | interface A { +b: B, -c: C } | interface A { readonly b: B, c: C } |
| ✅ | Generic Types | ||
| ❌ | Bounds | <A: string> | <A extends string> |
| ✅ | Union Types | number | boolean | number | boolean |
| ❓ | Disjoint unions | ||
| ✅ | Intersection Types | A & B | A & B |
| ❓ | Typeof types | ||
| ✅ | Typeof undefined | typeof undefined | undefined |
| ✅ | Type Casting | (a: A) | (a as A) |
| ✅ | Import default type | import type A from './b' | import A from './b' |
| ✅ | Import named type | import type { A } from './b' | import { A } from './b' |
| Done? | Flow | TypeScript | |
|---|---|---|---|
| ✅ | Keys | $Keys<A> | keyof A |
| ❌ | Values | $Values<A> | A[keyof A] |
| ✅ | ReadOnly | $ReadOnly<A> | Readonly<A> |
| ✅ | ReadOnlyArray | $ReadOnlyArray<A> | ReadonlyArray<A> |
| ✅ | Exact | $Exact<A> | A |
| ❌ | Difference | $Diff<A, B> | ? |
| ❌ | Rest | $Rest<A, B> | ? |
| ❌ | Property type | $PropertyType<T, k> | T[k] |
| ❌ | Element type | $ElementType<T, K> | T[k] |
| ❌ | Element type | $NonMaybeType<T> | NonNullable<T> (strictNullChecks) |
| ❌ | ObjMap | $ObjMap<T, F> | ? |
| ❌ | ObjMapi | $ObjMapi<T, F> | ? |
| ❌ | TupleMap | $TupleMap<T, F> | ? |
| ❌ | Call | $Call<F> | ReturnType |
| ❌ | Class | Class<A> | typeof A |
| ❌ | Shape | Shape<T> | Partial<T> |
| ❌ | Supertype | $Supertype<A> | any (deprecated) |
| ❌ | Subtype | $Subtype<A> | B extends A (deprecated) |
| ❌ | Existential type | * | any (deprecated) |
✅ Done
❌ Not implemented yet
❓ Status not known
All types of contributions are very much welcome. Check out our Contributing Guide for instructions on how to get started.
@esmbly/transformer-flow is a customization/extension of the flow-to-typescript project ( ❤️) which is released under the following MIT license.
Copyright 2017 Boris Cherny <boris@performancejs.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
An Esmbly transformer that transforms Flow files to TypeScript
We found that @esmbly/transformer-flow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.