Coding is as much a matter of personal growth as it is of logic and control-flow. I keep patience, curiosity, & exuberance in the same toolbox as vim and git.
*Opinions posted are my own*
looks good. Do you think static indexing will obviate these kinds of errors?
classFoo{declarestatictype:"a"|"b";}classBar{statictype="b";}consta=newBar();// @ts-expect-error: you're going to have to trust me on this oneif(a.constructor.type==='a')console.log('oops! a compiler error!');
This comes up a lot when duck-typing custom elements at run time.
in that example it wouldn't be of much help, but IIRC there's ongoing work elsewhere to type constructor as typeof T. if it was, rather than Function, it would work in your example i think
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
looks good. Do you think static indexing will obviate these kinds of errors?
This comes up a lot when duck-typing custom elements at run time.
in that example it wouldn't be of much help, but IIRC there's ongoing work elsewhere to type
constructorastypeof T. if it was, rather thanFunction, it would work in your example i think