Only import TypeScript types, not the whole module

3k views Asked by At

I have a project that already includes the required JavaScript files. However, I am trying to move some code into TS and take advantage of it. There's a library that I use (sweetalert2) that has been installed and is in node_modules (though not actually used from that location).

All I want to do is somehow include it in my TS files so that I get the Intellisense and type checks. Not actually import the code. If I import the code it does a whole lot of stuff that I don't need or want.

I think I've tried every variation of tsconfig and references and I can't get it to work. There must be a way!

Is there a way to just just reference the types so that you can take advantage in TypeScript and it doesn't complain?

1

There are 1 answers

1
Rubydesic On

You can use import type() to import only types.