Skip to content

Clarified TableCache onUpdate as optional#3471

Closed
PastelStoic wants to merge 1 commit into
clockworklabs:masterfrom
PastelStoic:patch-1
Closed

Clarified TableCache onUpdate as optional#3471
PastelStoic wants to merge 1 commit into
clockworklabs:masterfrom
PastelStoic:patch-1

Conversation

@PastelStoic
Copy link
Copy Markdown

The onUpdate method only exists on tables with a primary key; auto-generated types specify the existance of this method, but the class itself does not, a tripping hazard for generic implementations.

Description of Changes

Mark a method as optional.

API and ABI breaking changes

None.

Expected complexity level and risk

Complexity 1.

Testing

This makes no changes to the compiled JS code, and every instance of this method already treats it as optional. No testing should be needed.

The onUpdate method only exists on tables with a primary key; auto-generated types specify the existance of this method, but the class itself does not, a tripping hazard for generic implementations.

Signed-off-by: PastelStoic <pastelstoic@proton.me>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Oct 23, 2025

CLA assistant check
All committers have signed the CLA.

@gefjon gefjon requested a review from cloutiertyler October 23, 2025 16:41
@cloutiertyler
Copy link
Copy Markdown
Contributor

@PastelStoic can you please provide more information on what issue this is causing? That is meant to be an internal API used by generated bindings.

Also the existing tests are failing due to this change.

@PastelStoic
Copy link
Copy Markdown
Author

PastelStoic commented Oct 24, 2025

I ran into this issue when making a Preact version of the useTable React hook. Since TableCache.onUpdate is not typed as optional, I got the obvious "onUpdate is not a function" runtime error. I expected this would be a very minor change to types with no actual code effect, so there's clearly something I'm missing in the broader ecosystem. I'll close this, then reopen when I can properly set up tests. I do think the change is worth making for future expandability, allowing third-party utilities for other client frameworks (Svelte, Solid, etc).

@PastelStoic PastelStoic deleted the patch-1 branch October 24, 2025 12:12
@PastelStoic PastelStoic restored the patch-1 branch October 24, 2025 17:20
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.

3 participants