JS API: Rename the u2 Component.run scope helper to runInScope - #4015
Merged
Conversation
The u2 refactor put run<T>(fn) on the Component base. Every view and widget inherits it, so any subclass with its own run() stopped matching the base signature: TS2416: Property 'run' in type 'FunctionView' is not assignable to the same property in base type 'ViewBase' That is what breaks the Compute and DevTools package builds, both via FunctionView in libraries/compute-utils. No signature satisfies both, so one of the two names has to move. It should be this one. FunctionView.run is marked stability Stable and ships in @datagrok-libraries/compute-utils 1.46.9 on npm, so renaming it breaks callers outside this repo. Component.run is unpublished: datagrok-api on npm is 1.27.9, which predates u2, and @datagrok-libraries/u2 is not on npm at all. Renaming the helper costs nothing outside this repository. Every Component.run call passes an arrow, so `.run((` selects them exactly. The other run methods are untouched, verified by hand: action.run(this), runner.run(this.func, ...), host.run(name), host.run(DELETE) and _verbs.run(name). 52 call sites across 25 files, plus three error strings that name the helper. Verified against function-view.ts compiled on the current js-api sources: TS2416 at 774,16 before, none after, with FunctionView.run left alone. This also removes the need for the Tutorial.run rename that already landed; Tutorial.run could be restored if the published name matters. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The failure
ComputeandDevToolsare the two remaining packages failing to build on this error (both vialibraries/compute-utils):The u2 refactor put a scope helper on the
Componentbase:Every view and widget inherits it, so any subclass with its own
run()stops matching.Why rename this side rather than FunctionView
No signature satisfies both — a subclass may drop parameters but cannot return
Promise<void>where the base returnsT. One of the two names has to move, and publication status decides which:FunctionView.run(compute-utils)@stability StableComponent.run(u2)datagrok-apion npm is 1.27.9 (pre-u2);@datagrok-libraries/u2returns 404The new, unreleased, generically-named helper should yield to the released API.
Scope and precision
Every
Component.runcall passes an arrow, so.run((selects them exactly. 52 call sites across 25 files, plus three error strings naming the helper.The other
runmethods are deliberately untouched, checked by hand:Verified afterwards that no
.run((remains and all six of the above survive.Verification
function-view.tscompiled against the current js-api sources:function-view.ts(774,16)FunctionView.run()is unchanged, socompute-utils' public API is preserved.Note on #4010
This also removes the need for the
Tutorial.run→start()rename that already merged. I renamed on the consumer side there without checking npm —@datagrok-libraries/tutorialsis published at 1.7.8, so that change did alter a published API. Impact is small in practice (external tutorials implement the protected_run()hook rather than callingrun()), butTutorial.runcould be restored on top of this if the published name matters.Generated with Claude Code