general purpose codemods for flow
Converts object shape types to exact objects.
If you position the cursor inside a type annotation, only objects within that type annotation are converted.
If there is a selection, only objects within the selection are converted.
// @flow
type Foo = {
bar: number,
baz: Array<{
qux: number,
blah: $ReadOnly<{
blsdf: string,
}>,
glorb: {a: number}[],
...
}>,
}
// @flow
type Foo = {|
bar: number,
baz: Array<{|
qux: number,
blah: $ReadOnly<{| blsdf: string |}>,
glorb: {| a: number |}[],
|}>,
|}
Converts object shape types to inexact objects.
If you position the cursor inside a type annotation, only objects within that type annotation are converted.
If there is a selection, only objects within the selection are converted.
// @flow
type Foo = {|
bar: number,
baz: Array<{
qux: number,
blah: $ReadOnly<{|
blsdf: string,
|}>,
glorb: {a: number}[],
...
}>,
|}
// @flow
type Foo = {
bar: number,
baz: Array<{
qux: number,
blah: $ReadOnly<{ blsdf: string, ... }>,
glorb: { a: number, ... }[],
...
}>,
...
}
Converts mutable object shape and array types to readonly types.
If you position the cursor inside a type annotation, only objects and arrays within that type annotation are converted.
If there is a selection, only objects and arrays within the selection are converted.
// @flow
type Foo = {
bar: number
baz: Array<{
qux: number
blah: $ReadOnly<{
blsdf: string
}>
glorb: { a: number }[]
}>
}
// @flow
type Foo = $ReadOnly<{
bar: number
baz: $ReadOnlyArray<
$ReadOnly<{
qux: number
blah: $ReadOnly<{
blsdf: string
}>
glorb: $ReadOnlyArray<$ReadOnly<{ a: number }>>
}>
>
}>