fix(column): validate interface rather than the instance type#1442
fix(column): validate interface rather than the instance type#1442
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1442 +/- ##
==========================================
+ Coverage 89.23% 89.64% +0.41%
==========================================
Files 25 26 +1
Lines 706 705 -1
Branches 190 189 -1
==========================================
+ Hits 630 632 +2
+ Misses 63 59 -4
- Partials 13 14 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
We cannot use `instanceof` because two apps will have different libraries so the prototype is not the same and the check will always fail. Instead validate the column using the already existing validation method. Signed-off-by: Ferdinand Thiessen <[email protected]>
There was a problem hiding this comment.
Fixes the issue, but I'm not very fond of the solution..
IMO, validation properties is neither reliable (no guarantee it actually checks the type) nor direct way to check the type (we check properties, not type).
I'd either expect using classes and then check the constructor name (like instancof, but a string, so no cross-frontend issues). Or allowing using data objects and then adding a flag property like __view__ so we can only check a single private property added by the instance builder/creator.
And if the goal is to replace TS with JS in runtime, I'd consider using one of some good libraries to transform type declaration into validation, to not write the same checks over and over...
|
Agree. I think for the pure data objects like view, filter or column we should have a better way. |
We cannot use
instanceofbecause two apps will have different libraries so the prototype is not the same and the check will always fail.Instead validate the column using the already existing validation method.