Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft of fix for ChainableAttributeSpec being assigned to SharedType type attribute #54

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

remaininlight
Copy link

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 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)),
}
}

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.

None yet

1 participant