re: How to destructure a class instance without breaking "this" in JavaScript VIEW POST

re: Or just change the strings method to be an arrow class function (so this is lexically bound). Change strings(strings = false) { to strings = (str...

I believe you would have to do
this.strings = (strings = false) => {

but that would be a lot easier.


I am used to writing TypeScript, that arrow function syntax is valid TS class syntax, not really sure if it works natively in ES8.

It does work natively, I just preferred to use normal functions for this tutorial, maybe I could update it with an easier alternative with the arrow syntax. Arrow functions can be a bit ambiguous with this that's why i went with the other way

I am pretty sure that if you transpile your TS to target ES5 with that syntax it will just bind() the this in the output code, just need to test it 😄

code of conduct - report abuse