Skip to content

Conversation

@k0stik
Copy link
Member

@k0stik k0stik commented Nov 7, 2023

No description provided.

const Entity = this.constructor as typeof InMemoryEntity;
clone<T extends InMemoryEntity>(extraContext?: object): T {
// @ts-ignore
const object: T = new this.constructor({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to use TS ignore?

Copy link
Member Author

@k0stik k0stik Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, typescript defines this.constructor as an ordinary function, not a constructor of some particular type. Everytime I try to access some properties or build a new object via new this.constructor it throws an error.

Changed this with typecasting typeof this as suggested here
https://stackoverflow.com/questions/33387318/access-to-static-properties-via-this-constructor-in-typescript

package.json Outdated
"@babel/register": "^7.16.0",
"@babel/runtime-corejs3": "7.16.8",
"@exabyte-io/esse.js": "2023.11.1-0",
"@exabyte-io/esse.js": "git+https://github.com/Exabyte-io/esse.git#update/SOF-7096",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be published version

@k0stik k0stik merged commit 047b604 into main Dec 1, 2023
@k0stik k0stik deleted the update/SOF-7096 branch December 1, 2023 12:30
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.

3 participants