user11081980 user11081980 - 3 months ago 32
TypeScript Question

TypeScript just for typings, JavaScript for the rest

I really like the TypeScript's typing feature that shows all the properties and methods of an object. This is really useful (among other things) when I get a JSON object from my Web API and I know what properties it has (as opposed to using Dev Tools to inspect the object).

But I really like plain JavaScript and I just don't want to switch to TypeScript. That's my personal preference, regardless of the other advantages of TypeScript.

My question is - can I use TypeScript just for typings? I don't want to use class, or inheritance, or the other features.

If not, another alternative is to use JSDoc and document the objects and rely on the IDE's IntelliSense. Are there more alternatives?


Typescript is just javascript with type annotations as optional syntax. You can keep coding in your javascript-only-syntax and only benefit from the typings of the .d.ts files as configured in your tsconfig. If you don't want to use classes, inheritance or the other features then just don't use them. Your pure javascript code won't get any rewrites.

Typescript compiler and IDE integrations, though, are what know the types from the libraries/definitions (which is what you're asking for).

If that's what it takes for you to start using it, fine, but I'm guessing that you'll start allowing a type annotation here or there in your code so that you can very selectively benefit among sections of your own code the same way you enjoy having accurate intellisense from the libraries/services you consume.