Repository navigation
build(srcts): Convert Flow to TypeScript and build with esbuild - #150
Merged
Merged
Conversation
Rename srcjs/*.js to .ts and rewrite the Flow-only syntax: casts become `as`, maybe types become `T | null | undefined`, %checks becomes a type guard, and $Values / $ReadOnlyArray use TypeScript forms. tsc runs with strict off for now. Replace grunt, webpack 4, Babel, and Flow with esbuild plus `tsc`. This drops the polyfills and the --openssl-legacy-provider workaround. Linting is out of the build until eslint and prettier are updated.
schloerke
added this pull request to stack #153
October 20, 2026 17:31
Use the same tsc and esbuild target as rstudio/shiny (es2021). The viewer only runs inside Shiny apps, so it never needs an older target. bin/check_shiny_target.js reads shiny's tsconfig.json and srcts/build/_build.ts from GitHub and fails if either target differs from ours. The new workflow runs it on PRs that touch the build config and weekly, since shiny can change on its own.
The prev/next buttons were bound straight to the button functions, so jQuery's click event arrived as `cytoOptions` and was merged into the cytoscape layout options. Wrap each in an arrow function instead of hiding it with `as any`. Also type cytoscape event targets as an element or the core, with an `isCore()` guard in place of three `as unknown` casts, and give `hasLength()` an honest signature that always returns a boolean.
babel-eslint, eslint-plugin-flowtype, @babel/core, and .eslintrc.js only served the Flow lint setup and cannot read TypeScript. The next change in the stack adds the TypeScript lint setup.
23 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Converts the viewer from Flow-typed JavaScript to TypeScript and renames
srcjs/tosrcts/to match rstudio/shiny. The Flow syntax was edited in place, so git still sees renames and the diff stays small: casts becameas,?TbecameT | null | undefined,%checksbecame a type guard, Flow'sObjectbecameany, andLogStatesis nowas constsoswitch (entry.action)narrows.tscruns withstrictoff here; rstudio/reactlog#154 turns it on. TypeScript is pinned to 6.0 because typescript-eslint (next PR) does not support 7.Replaces grunt, webpack 4, Babel, Flow, flow-typed, and the polyfills with esbuild plus
tsc, targeting es2021 like rstudio/shiny (which also uses no polyfills).bin/check_shiny_target.jsand the newshiny-target.yamlworkflow fail if our tsc or esbuild target drifts from shiny's; it runs on PRs that touch the build config and weekly.npm run buildis nowtypecheck+build-onlyand builds in under 0.1s. The bundle drops from 679 KB to 574 KB, and the--openssl-legacy-providerworkaround is gone. Linting is out of the build until the next PR, because eslint 5 and prettier 1 can't parse TypeScript, and the Flow-onlybabel-eslint,eslint-plugin-flowtype, and.eslintrc.jsare removed here. The prev/next buttons now call their functions through an arrow, so jQuery's click event no longer ends up in the cytoscape layout options. Cytoscape event targets are typed as an element or the core, with anisCore()guard instead ofas unknowncasts.Checked by loading the old and new bundles in a browser with the default log and running the same 13 actions (every nav button, arrow keys, Home/End, search). Tick, node and edge counts, the log entry text, and the timeline position all matched, and so did the screenshots. No console errors.