You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge branch '2026-05-typescript-conversion' into master
Convert the library from Flow to TypeScript and prep the 4.0.0 release.
Public runtime API is unchanged. Type-delivery channel changes:
- Bundled .d.ts now ships in build/ (via package.json#types).
- *.js.flow shims removed. Flow is no longer supported.
- @types/react-resizable on DefinitelyTyped is no longer needed.
See CHANGELOG.md (4.0.0) for migration notes and the link to the last
Flow-annotated source for users who still need to vendor Flow types.
description: Convert react-resizable from Flow to TypeScript
3
+
---
4
+
5
+
# Goal: Convert react-resizable from Flow to TypeScript
6
+
7
+
## Why
8
+
9
+
The repo is currently typed with Flow (v0.153.0, pinned to a 2020 version). Flow is no longer well-supported in the React ecosystem and most consumers expect TypeScript declarations. Convert the library source, tests, and build pipeline to TypeScript while preserving all public runtime behavior (including PropTypes) and the existing build output shape (CommonJS lib + ambient declarations consumed via `build/`).
10
+
11
+
## Constraints
12
+
13
+
- No behavior changes. Snapshots and unit tests must continue to pass.
14
+
- The public API surface is unchanged. `require('react-resizable').Resizable` and `.ResizableBox` must keep working.
15
+
- Keep `prop-types` runtime validation in place (downstream JS consumers rely on it).
16
+
- Continue to emit a CommonJS bundle from `build/` plus type declarations next to each module.
17
+
- Drop Flow (`flow-bin`, `.flowconfig`, `flow-typed/`, `@babel/preset-flow`, `// @flow` pragmas).
18
+
19
+
## Acceptance criteria
20
+
21
+
-[ ]`yarn install` succeeds.
22
+
-[ ]`yarn typecheck` (tsc --noEmit) passes with no errors.
23
+
-[ ]`yarn lint` passes (ESLint with @typescript-eslint).
24
+
-[ ]`yarn test` passes (all existing tests, including snapshots).
- Rename `.test.js` → `.test.tsx` where JSX is used, otherwise `.test.ts`.
43
+
- Fix any test typings that need help (e.g., enzyme/testing-library queries).
44
+
- Re-record snapshots only if structural output is unchanged.
45
+
5.**Build pipeline**:
46
+
-`build.sh` runs babel (transpile .ts/.tsx → JS) and `tsc --emitDeclarationOnly` for .d.ts files.
47
+
- Drop the `cp *.js *.js.flow` step.
48
+
6.**package.json scripts**:
49
+
-`lint`: ESLint over `.ts,.tsx`.
50
+
-`typecheck`: `tsc --noEmit`.
51
+
- Remove the `flow` script.
52
+
7.**ESLint**: update `eslint.config.js` to parse TS with `@typescript-eslint/parser` and include `@typescript-eslint` rules at "recommended" level. Keep existing react/jest plugins.
53
+
8.**Examples**: keep `examples/example.js` as JS — out of scope for this conversion. Update webpack to still build it.
54
+
9.**Run the acceptance gate**: `yarn install && yarn typecheck && yarn lint && yarn test && yarn build`. Fix everything until green.
55
+
10.**Commit**: one commit, message `chore: convert library from Flow to TypeScript`.
56
+
57
+
## Out of scope
58
+
59
+
- Examples directory (`examples/*.js`).
60
+
- API/behavior changes.
61
+
- Bumping major dependency versions beyond what's needed for TS to work.
62
+
- Migrating ESLint plugins beyond what's needed for TS parsing.
Copy file name to clipboardExpand all lines: README.md
+73-30Lines changed: 73 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,12 @@ A simple widget that can be resized via one or more handles.
11
11
You can either use the `<Resizable>` element directly, or use the much simpler `<ResizableBox>` element.
12
12
13
13
See the example and associated code in [ExampleLayout](https://github.com/react-grid-layout/react-resizable/blob/master/examples/ExampleLayout.js) and
14
-
[ResizableBox](https://github.com/react-grid-layout/react-resizable/blob/master/lib/ResizableBox.js) for more details.
14
+
[ResizableBox](https://github.com/react-grid-layout/react-resizable/blob/master/lib/ResizableBox.tsx) for more details.
15
15
16
16
## Table of Contents
17
17
18
18
-[Installation](#installation)
19
+
-[TypeScript](#typescript)
19
20
-[Compatibility](#compatibility)
20
21
-[Usage](#usage)
21
22
-[Resizable](#resizable)
@@ -47,20 +48,59 @@ Or import it in your CSS:
47
48
48
49
If you're using a bundler that doesn't support CSS imports, you can find the styles at `node_modules/react-resizable/css/styles.css` and include them manually.
49
50
51
+
## TypeScript
52
+
53
+
As of `4.0.0`, the library is authored in TypeScript and ships bundled type
54
+
declarations in `build/*.d.ts`. You **do not** need to install
55
+
`@types/react-resizable`; if you previously installed it, remove it so the
56
+
bundled types take precedence:
57
+
58
+
```bash
59
+
npm uninstall @types/react-resizable
60
+
# or
61
+
yarn remove @types/react-resizable
62
+
```
63
+
64
+
Public types are re-exported from the package root:
65
+
66
+
```ts
67
+
import {
68
+
Resizable,
69
+
ResizableBox,
70
+
// types
71
+
typeResizeCallbackData,
72
+
typeResizeHandleAxis,
73
+
typeAxis,
74
+
typePropsasResizableProps,
75
+
} from'react-resizable';
76
+
```
77
+
78
+
### Flow
79
+
80
+
Flow is no longer supported as of `4.0.0`. Earlier versions shipped
81
+
`*.js.flow` sidecar files generated from the Flow-annotated source; those
82
+
have been removed.
83
+
84
+
If you still need Flow types, you can vendor the last Flow-annotated source
85
+
locally from the [`3.2.0` tag](https://github.com/react-grid-layout/react-resizable/tree/db2e37eda85fb21b1864e36b01c4922452f28418/lib).
86
+
They will not be updated to reflect changes landing after `4.0.0`. The
87
+
official recommendation is to migrate to TypeScript.
*[`<Resizable>`](https://github.com/react-grid-layout/react-resizable/blob/master/lib/Resizable.js): A raw component that does not have state. Use as a building block for larger components, by listening to its callbacks and setting its props.
63
-
*[`<ResizableBox>`](https://github.com/react-grid-layout/react-resizable/blob/master/lib/ResizableBox.js): A simple `<div {...props} />` element that manages basic state. Convenient for simple use-cases.
102
+
*[`<Resizable>`](https://github.com/react-grid-layout/react-resizable/blob/master/lib/Resizable.tsx): A raw component that does not have state. Use as a building block for larger components, by listening to its callbacks and setting its props.
103
+
*[`<ResizableBox>`](https://github.com/react-grid-layout/react-resizable/blob/master/lib/ResizableBox.tsx): A simple `<div {...props} />` element that manages basic state. Convenient for simple use-cases.
64
104
65
105
### `<Resizable>`
66
106
@@ -124,43 +164,46 @@ class Example extends React.Component {
124
164
125
165
These props apply to both `<Resizable>` and `<ResizableBox>`. Unknown props that are not in the list below will be passed to the child component.
0 commit comments