Occasionally, you may find yourself in situations where you have to work with packages that were not designed with TypeScript in mind. For instance, I am currently using the two.js
package in a React project with TypeScript strict mode enabled. It has been challenging for me to correctly type each variable since many functions' return types are unclear.
When I resort to using any
or omitting a type altogether, I encounter bothersome errors like the one indicating that the variable 'implicitly has an 'any' type.' This constant battle with the compiler is disrupting my focus on actual development tasks.
Unlike other programming languages, JavaScript's typeof
and instanceof
methods prove inadequate for revealing the exact class or type of an object. The former only returns 'object' for custom objects, rendering it less useful for type checking purposes.
Although I appreciate the benefits of TypeScript, this particular issue is proving to be quite frustrating. Is there a reliable method or workaround to address this dilemma? Despite conducting extensive online research, I have yet to discover a definitive solution.