WatermelonDB
WatermelonDB copied to clipboard
TypeError: Cannot destructure property 'configurable' of 'descriptor' as it is undefined.
When I try to use my models in jest tests, the use of @lazy
triggers this error.
Note that I use typescript on my models.
I noticed that lazy
doesn't use the makeDecorator
call as other decorators use... may this be the reason?
https://github.com/Nozbe/WatermelonDB/blob/4e7abb5ccbdccc018d657673ccc2c72ae06d0681/src/decorators/lazy/index.js#L15
https://github.com/Nozbe/WatermelonDB/blob/4e7abb5ccbdccc018d657673ccc2c72ae06d0681/src/decorators/date/index.js#L22
How to use it then? Did you resolve the issue?
@castroCrea I switched from ts-jest to babel and it fixed the issue.
I am moving to a monorepo and after moving my models to a common package I am getting the same error. The package is compiled with the babel plugins that are mentioned in the installation. Any ideas what could be causing it?
{
"presets": ["@babel/react", "@babel/preset-env"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
[
"@babel/plugin-transform-runtime",
{
"helpers": true,
"regenerator": true
}
]
],
"targets": { "esmodules": true }
}
Why is this closed? I'm having the same issue with NextJS which uses SWC compiler
@reyalpsirc have you resolved the issue? I've faced the same issue
@reyalpsirc have you resolved the issue? I've faced the same issue
No, I stopped using Watermelondb with NextJS on the project I was starting. The only other solution is to avoid using the lazy decorator
Still running into this issue when trying to run import a model with a @lazy
decorator in a Node script. Also a monorepo setup.
/node_modules/@nozbe/watermelondb/decorators/lazy/index.js:16
configurable: configurable,
^
TypeError: Cannot destructure property 'configurable' of 'descriptor' as it is undefined.
at lazy (/node_modules/@nozbe/watermelondb/decorators/lazy/index.js:16:19)
All my node script is doing is trying to import a model with a @lazy
decorator.
@radex is there something else that needs to be done to get this working with Node? I've followed the Node setup guide already.
For others coming across this issue, I was able to get a workaround by changing how I set up my @lazy
methods:
Instead of:
@lazy commenters = this.collections.get('users').query(
Q.on('comments', 'post_id', this.id)
)
Do:
get commenters () {
return this.collections.get('users').query(
Q.on('comments', 'post_id', this.id)
)
}
Note the removal of the @lazy
decorator. Since TypeScript/JavaScript getters are already lazily evaluated, I think this should be OK. Any concerns with this @radex?