Clarified TableCache onUpdate as optional#3471
Conversation
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>
|
@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. |
|
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). |
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.