Using a TypeScript library in plain JS

Using a TypeScript library in plain JS


Suppose I have a library that’s made with TypeScript (with all its static type-checking goodness). The TS lib’s API has everything typed (function return types, function parameter types, etc.).

Now suppose I want to use that lib in regular JS. Then I’ll have to use the JS version of that lib, losing the information as to what types are used by that lib’s API.

Does that mean the lib functions still have to check their arguments are the right type anyway (using typeof, for example)?


No, the typechecking part is completely bolted on top of regular JS: if you remove that you lose any type checking.