downloads
Across all versions.
Download trend unavailable.
compatibility
Runtime metadata.
Across all versions.
Download trend unavailable.
Runtime metadata.
flow-upgradeA utility for upgrading your codebase to the latest version of Flow.
Install using yarn add flow-upgrade. We expect prettier to be installed as a peer dependency wherever you are running flow-upgrade.
You can then run:
yarn run flow-upgrade <current flow version> <target flow version>You may also use npx:
npx flow-upgrade <current flow version> <target flow version>We also supply the flow-codemod binary:
yarn run flow-codemod <codemod name>Estimated unpacked size across 53 packages.
5.8 MB
Includes dependencies.
gabelevi
gabelevi@gmail.com
If you just want to run a codemod without specifying Flow versions.
allBy default, Flow will only upgrade files that have an // @flow header comment.
If you want to upgrade all of your JavaScript files you may pass in the --all:
yarn create flow-upgrade --allprettierrcPath to a .prettierrc file to use.
Upgrade codemods rely upon prettier to print the resulting code after transformation.
If this is not provided, we will just use the defaults.
Converts static object assignments (e.g. const o = {}; o.a = 1;) to inline properties (e.g. const o = {a: 1};).
Run with yarn run flow-codemod collapseObjectInitialization.
Replaces T: {} with T: {...} in type parameter bounds. The former is almost always wrong.
Run with yarn run flow-codemod typeParameterBoundExactEmptyObjectToInexact.
Converts implicitly inexact object type syntax {} to explicitly inexact {...}.
Run with yarn run flow-codemod convertImplicitInexactObjectTypes.
Converts explicitly exact object type syntax {| |} to be just { }. Object types are exact by default.
Also removes comments that only set the ambiguous-object-type lint (e.g. // flowlint ambiguous-object-type:error).
Run with yarn run flow-codemod removeExplicitlyExactObjectTypeSyntax.
Names every unnamed param in function types, including declare function signatures (e.g. (string) => void becomes (v: string) => void), as required by experimental.require_function_type_param_name.
Run with yarn run flow-codemod nameFunctionTypeParams.
Labels every unlabeled index signature key (e.g. {[string]: T} becomes {[key: string]: T}), as required by experimental.require_dictionary_key_label.
String and number literal keys like {['a']: T}, and keys naming a value like {[K]: T} where K is a const, are computed property keys rather than index signatures, so they are left alone.
Run with yarn run flow-codemod nameIndexerKeys.
Removes annotations nested inside of destructuring (e.g. const [o: number] = foo;). These are not valid Flow syntax.
Run with yarn run flow-codemod removeAnnotationsInDestructuring.
Part of the upgrade to 0.176
Removes useless duplicate class properties and fixes bad constructor binding in those classes.
Run with yarn run flow-codemod removeDuplicateClassProperties.
Part of the upgrade to 0.170
$Partial to PartialRenames usages of the $Partial utility type to its new name, Partial.
Run with yarn run flow-codemod renamePartial.
Part of the upgrade to 0.201
$Shape to PartialConverts usages of the deprecated and unsafe $Shape utility type to its replacement, Partial.
Run with yarn run flow-codemod convertShapeToPartial.
(x: T) to as expressions x as TConverts usages of the old casting syntax (x: T) to the new casting syntax x as T.
Run with yarn run flow-codemod typeCastToAsExpression.
Converts usages of the internal React types like React$Node to public facing ones like React.Node.
Run with yarn run flow-codemod replaceReactDollarUtilityTypes.
$TEMPORARY$* typesConverts:
$TEMPORARY$object<{props}> to $ReadOnly<{props}>$TEMPORARY$array<T> to $ReadOnlyArray<T>$TEMPORARY$number<42> annotations to number$TEMPORARY$string<"foo"> annotations to stringReact.AbstractComponent<...> typesConverts:
React.AbstractComponent<Props> to React.ComponentType<Props>React.ComponentProps<React.AbstractComponent<Props, Instance>> to PropsReact.ElementRef<React.AbstractComponent<Props, Instance>> to InstanceReact.ElementRef<React.AbstractComponent<Props> to mixedConverts legacy Flow utility types to TypeScript-compatible equivalents:
$NonMaybeType<T> to NonNullable<T>$ReadOnly<T> to Readonly<T>$ReadOnlyArray<T> to ReadonlyArray<T>$ReadOnlyMap<K, V> to ReadonlyMap<K, V>$ReadOnlySet<T> to ReadonlySet<T>$Keys<T> to keyof T$Values<T> to Values<T>mixed to unknownRun with yarn run flow-codemod convertLegacyUtilityTypes.
^2.0.1
6.0.1
^17.0.1
18.2.0
^7.3.7
7.8.6
10.1.0
11.4.1
^6.0.0
8.0.0
^0.340.0
0.340.0
^0.340.0
0.340.0
^0.340.0
0.340.0
^0.340.0
0.340.0
^1.2.0
2.0.4
^7.18.6
7.25.9