1
lorentz
4y

I have a readonly object property foo on a typescript class. When I create an instance bar by calling the constructor, bar.foo doesn't compare equal to this.foo as seen from within bar several async calls later. What could I have possibly fucked up?

Comments
  • 0
    Need to see code to say. Could be a number of reasons including the return type of Foo(), and where Foo() is called from due to JavaScript 'this' invocation patterns.
  • 1
    Do you call the constructor or do you use the new keywords 🤔

    You fucked up good I’d say
  • 0
    @example-user I use new. I also have a relatively strict eslint config so it wouldn't even let me do otherwise.
  • 0
    Okay I figured it out, it had nothing to do with typescript, I just had a leftover client on the same server that was ahead in the handler tables and thus replied quicker than the client I was monitoring,. The monitored one thought that its messages were passing through so it updated its state to match the leech up to a certain point, which is why I couldn't tell them apart while debugging and thought that they were the same object and the connection instance changed over time.
Add Comment