this.setDataValue() does not type-check correctly inside an attribute setter
See original GitHub issueI want use ‘setDataValue’, ‘getDataValue’ in typescript,so I write in this way.
this.setDataValue('points', JSON.stringify(val)); // error
but it’s error, so I write like this.
const Model = app.model.define(
'area',
{
areaId: {
type: INTEGER,
primaryKey: true,
allowNull: false,
autoIncrement: true,
},
name: { type: STRING(32), allowNull: false },
points: {
type: TEXT,
set(val) {
// this.setDataValue('points', JSON.stringify(val)); //error.
Model.prototype.setDataValue.bind(this)( //correct
'points',
JSON.stringify(val),
);
},
get() {
return JSON.parse(Model.prototype.getDataValue.bind(this)('points'));
},
},
},
{
timestamps: false,
},
) as IArea;
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Sequelize type changing getter/setter with Typescript
I got a red line under the extras saying: Type '{ [key: string]: any; }' is not assignable to type 'string'.
Read more >Getters, Setters & Virtuals - Sequelize
Sequelize allows you to define custom getters and setters for the attributes of your models.
Read more >Changelog - Unified Automation GmbH
It was not set correctly for AbsolutDeadband. - In UaMonitoredItem, skip the deadband check if sdkMustHandleAbsoluteDeadband is set to false.
Read more >The @property Decorator in Python: Its Use Cases ...
How you can use @property to define getters, setters, and deleters. ... This instance attribute is public because its name doesn't have a ......
Read more >qooxdoo Documentation
The qooxdoo developer does not even have to know ... Removal of debug statements within the application code before deployment.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rolandleth Thanks! You too!
Oh, I totally missed OP’s
bind(this)
😞 I thought it behaves differently because I’m using classes, which is why I also thought about a different issue. Thank you for thecall(this...
suggestion!Have a great Saturday, @papb!