Type-R
Type-R copied to clipboard
Draft of fix for ChainableAttributeSpec being assigned to SharedType type attribute
When a shared type is used on a record in version 3.0.8 an error is thrown when assignment to it is attempted:
Uncaught TypeError: Right-hand side of 'instanceof' is not callable at SharedType.convert (shared.ts:90) at SharedType.doUpdate (shared.ts:56) at setAttribute (updates.ts:56) at AppState.set (any.ts:108) at onEdit (main.jsx:69) at HTMLUnknownElement.callCallback (react-dom.development.js:540) at Object.invokeGuardedCallbackDev (react-dom.development.js:579) at Object.invokeGuardedCallback (react-dom.development.js:436) at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:450) at executeDispatch (react-dom.development.js:834)
This seems to be because in these cases the type attribute on SharedType is a ChainableAttributeSpec<Function> rather than a Transactional type. This pull request is very crude, largely bypassing the type system, I'm not precisely sure how the type inheritance hierarchy is supposed to fit together - please advise how this PR could be improved.
You should be able to replicate the bug using an example such as this and assigning to the editing attribute:
@define class AppState extends Record { static attributes = { editing : shared(type(User)), } }