Skip to content

Migrate Flow → TypeScript, upgrade deps, remove Lerna#446

Merged
gre merged 1 commit into
masterfrom
chore/2025-upgrades
Mar 19, 2026
Merged

Migrate Flow → TypeScript, upgrade deps, remove Lerna#446
gre merged 1 commit into
masterfrom
chore/2025-upgrades

Conversation

@gre
Copy link
Copy Markdown
Owner

@gre gre commented Mar 19, 2026

Summary

  • Flow → TypeScript: Convert all 27 source files across 5 packages (gl-react, gl-react-dom, gl-react-headless, gl-react-expo, gl-react-native) from Flow (.js) to TypeScript (.ts/.tsx)
  • Remove Lerna: Yarn workspaces handle everything; delete lerna.json
  • Upgrade deps: Jest 26 → 29, remove deprecated Babel proposal plugins, upgrade React in tests to 18.3.1
  • Build modernization: Replace @babel/preset-flow + flow-copy-source with @babel/preset-typescript + tsc --emitDeclarationOnly for .d.ts generation
  • Simplify cookbook-v2: Remove Babel Flow-stripping vite plugin (no longer needed since sources are TypeScript)

Test plan

  • yarn install — no errors
  • Babel build compiles all 32 files across 3 testable packages
  • yarn test — 40/40 tests pass
  • yarn workspace gl-react-cookbook-v2 exec vite build — builds successfully
  • CI green on GitHub Actions

🤖 Generated with Claude Code

@gre gre force-pushed the chore/2025-upgrades branch from 359a026 to 98881bb Compare March 19, 2026 13:17
@gre gre requested a review from Copilot March 19, 2026 13:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the gl-react monorepo from Flow to TypeScript, modernizes the build/type pipeline around TS declarations, and removes Lerna in favor of Yarn workspaces—alongside test/dependency upgrades and cookbook-v2 Vite simplifications.

Changes:

  • Converted gl-react* package sources from Flow (.js) to TypeScript (.ts/.tsx) and removed Flow configs/typings.
  • Updated build/test tooling (Babel preset-typescript, Jest 29, React test deps) and added CI typecheck step.
  • Removed Lerna usage (lerna.json) and simplified cookbook-v2 Vite configuration now that sources are TS.

Reviewed changes

Copilot reviewed 67 out of 78 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tsconfig.json Adds root TS solution config with project references.
scripts/build.sh Updates build to compile TS/TSX with Babel and run tsc for declarations.
packages/tests/package.json Upgrades Jest/React test deps and trims deprecated Babel plugins.
packages/tests/babel.config.js Simplifies Babel config for tests (keeps Flow preset for Flow-typed tests).
packages/tests/tests/snapshots/all.js.snap Updates snapshots for Jest 29 formatting.
packages/tests/.flowconfig Removes Flow config for tests package.
packages/tests/.eslintrc.js Removes per-package ESLint config.
packages/gl-react/tsconfig.json Adds per-package TS config (composite, declaration output, typeRoots).
packages/gl-react/src/types/webgltexture-loader.d.ts Adds TS ambient module typings for texture loader packages.
packages/gl-react/src/types/typedarray-pool.d.ts Adds TS ambient typings for typedarray-pool.
packages/gl-react/src/types/ndarray.d.ts Adds TS ambient typings for ndarray.
packages/gl-react/src/types/invariant.d.ts Adds TS ambient typings for invariant.
packages/gl-react/src/types/gl-shader.d.ts Adds TS ambient typings for gl-shader.
packages/gl-react/src/index.ts Removes Flow pragma from entrypoint.
packages/gl-react/src/helpers/log.ts Ports helper to TS and improves non-browser safety.
packages/gl-react/src/helpers/log.js Deletes Flow/JS version of log helper.
packages/gl-react/src/helpers/invariantNoDependentsLoop.ts Removes Flow pragma during TS migration.
packages/gl-react/src/genId.ts Ports genId helper to TS.
packages/gl-react/src/genId.js Deletes Flow/JS version of genId.
packages/gl-react/src/createSurface.tsx Ports Surface factory to TS and updates types/nullability.
packages/gl-react/src/copyShader.ts Removes Flow pragma during TS migration.
packages/gl-react/src/connectSize.tsx Ports HOC to TS and modernizes context typing.
packages/gl-react/src/Visitors.ts Adjusts global visitor storage for TS typing.
packages/gl-react/src/VisitorLogger.ts Ports visitor logger to TS typing.
packages/gl-react/src/Visitor.ts Replaces Flow Visitor definitions with TS interface/class.
packages/gl-react/src/Visitor.js Deletes Flow/JS Visitor file.
packages/gl-react/src/Uniform.ts Ports Uniform helper to TS with as const tags.
packages/gl-react/src/Shaders.ts Ports shader registry/types to TS, updates generics/mapped types.
packages/gl-react/src/Node.tsx Ports core Node implementation to TS and updates internal types.
packages/gl-react/src/NearestCopy.tsx Ports component to TS and updates ref nullability.
packages/gl-react/src/LinearCopy.tsx Ports component to TS and updates ref nullability.
packages/gl-react/src/GLSL.ts Ports GLSL tag helper to TS.
packages/gl-react/src/GLSL.js Deletes Flow/JS GLSL helper.
packages/gl-react/src/GLContext.ts Ports GLContext to TS and sets explicit default context value.
packages/gl-react/src/GLContext.js Deletes Flow/JS GLContext file.
packages/gl-react/src/Bus.tsx Ports Bus to TS and updates context typing.
packages/gl-react/package.json Adds types entry and removes Flow artifacts from published files.
packages/gl-react/flow/typedarray-pool.js Deletes Flow libdef.
packages/gl-react/flow/ndarray.js Deletes Flow libdef.
packages/gl-react/flow/lru.js Deletes Flow libdef.
packages/gl-react/flow/invariant.js Deletes Flow libdef.
packages/gl-react/flow/gl-shader.js Deletes Flow libdef.
packages/gl-react/.flowconfig Removes Flow config for gl-react package.
packages/gl-react-native/tsconfig.json Adds per-package TS config for gl-react-native.
packages/gl-react-native/src/index.ts Removes Flow pragma during TS migration.
packages/gl-react-native/.flowconfig Removes Flow config for gl-react-native.
packages/gl-react-headless/tsconfig.json Adds per-package TS config for headless implementation.
packages/gl-react-headless/src/types/raf.d.ts Adds ambient typings for raf.
packages/gl-react-headless/src/types/gl.d.ts Adds ambient typings for gl (headless-gl).
packages/gl-react-headless/src/loseGL.ts Ports loseGL helper to TS.
packages/gl-react-headless/src/loseGL.js Deletes JS loseGL helper.
packages/gl-react-headless/src/index.tsx Ports headless Surface implementation to TS.
packages/gl-react-headless/src/getContext.ts Ports getContext helper to TS.
packages/gl-react-headless/src/getContext.js Deletes JS getContext helper.
packages/gl-react-headless/package.json Adds types entry and removes Flow artifacts from published files.
packages/gl-react-headless/.flowconfig Removes Flow config for gl-react-headless.
packages/gl-react-expo/tsconfig.json Adds per-package TS config for expo implementation.
packages/gl-react-expo/src/index.ts Removes Flow pragma during TS migration.
packages/gl-react-expo/src/GLViewNative.tsx Ports GLView native wrapper to TS and adjusts Expo-specific calls.
packages/gl-react-expo/.flowconfig Removes Flow config for gl-react-expo.
packages/gl-react-dom/tsconfig.json Adds per-package TS config for DOM implementation.
packages/gl-react-dom/src/types/raf.d.ts Adds ambient typings for raf.
packages/gl-react-dom/src/index.ts Removes Flow pragma and updates mapRenderableContent typing.
packages/gl-react-dom/src/getContext.ts Ports getContext helper to TS and expands legacy WebGL context fallbacks.
packages/gl-react-dom/src/getContext.js Deletes JS getContext helper.
packages/gl-react-dom/src/GLViewDOM.tsx Ports GLViewDOM to TS and updates nullability and prop typing.
packages/gl-react-dom/package.json Adds types entry and removes Flow artifacts from published files.
packages/gl-react-dom/.flowconfig Removes Flow config for gl-react-dom.
packages/cookbook/.flowconfig Removes Flow config for cookbook package.
packages/cookbook-v2/vite.config.ts Removes Flow-stripping Babel/esbuild plugins; keeps a lightweight global shim.
packages/cookbook-v2/package.json Removes Flow preset dependency from cookbook-v2.
package.json Removes Lerna-based publish flow; adds typecheck script; updates build/prettier scripts and devDeps.
lerna.json Removes Lerna configuration.
babel.config.js Switches Babel from Flow preset to TypeScript preset; removes deprecated proposal plugins.
CLAUDE.md Updates repo docs to reflect TypeScript + Yarn workspaces build/typecheck flow.
.gitignore Ignores cookbook-v2 dist/ output.
.github/workflows/ci-tests.yml Adds yarn typecheck; updates Babel build command for TS/TSX.
Comments suppressed due to low confidence (1)

packages/gl-react/src/createSurface.tsx:345

  • Array.prototype.map() is used here purely for side-effects; since the returned array is ignored, this should be forEach() to avoid allocating an unused array and to make intent clearer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread scripts/build.sh Outdated
Comment on lines +15 to +16
# Generate TypeScript declaration files
tsc --emitDeclarationOnly
Comment thread package.json Outdated
"test-rewrite-snapshots": "cd packages/tests && yarn test -- -u",
"clean": "rm -rf node_modules packages/*/node_modules/ packages/*/lib",
"publish": "yarn && lerna run clean && yarn build && lerna publish --registry=https://registry.npmjs.org/"
"typecheck": "tsc --noEmit",
Comment on lines +6 to +8
let gl: WebGLRenderingContext | null = null;
if (version === "webgl2" || version === "auto") {
gl = canvas.getContext("webgl2", opts) as WebGLRenderingContext | null;
@@ -0,0 +1,3 @@
export default function loseGL(gl: WebGLRenderingContext) {
(gl.getExtension("STACKGL_destroy_context") as any).destroy();
- Convert all 27 source files across 5 gl-react* packages from Flow (.js) to TypeScript (.ts/.tsx)
- Add tsconfig.json with project references; add .d.ts for gl-shader, typedarray-pool, ndarray, etc.
- Remove Lerna (yarn workspaces suffice), delete lerna.json
- Upgrade Jest 26 → 29, remove deprecated Babel proposal plugins
- Replace @babel/preset-flow with @babel/preset-typescript in build
- Remove flow-copy-source; build script now uses tsc --emitDeclarationOnly for .d.ts
- Simplify cookbook-v2 vite config (no more Babel Flow-stripping plugin)
- Update CI workflow accordingly
- All 40/40 tests pass

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gre gre force-pushed the chore/2025-upgrades branch from 98881bb to 6b562d7 Compare March 19, 2026 13:47
@gre gre merged commit 77d1a72 into master Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants