DEV Community

Discussion on: TypeScript Done Wrong

iacons profile image
Iacovos Constantinou

Nice article! While writing TS is really important to keep in mind how JS works behind the scenes like for example the private properties you mentioned.

Another edge case to have in mind is when checking instanceof with variables. Consider the following example where we check dynamically that a variable is an instance of a dynamically provided class name (both myInstance and myClass are variables)

if (myInstace instanceof myClass)

The above will be always false when transpilling to JS because the typescript class name is lost.