Use a TypeScript Definition Without Importing

There may come a time where you want to reference types in your TypeScript file without importing the code. This is common if you have a script tag somewhere else that is importing JavaScript from a public CDN of a popular library.

To import the type definition without importing the library, you can use the triple slash refence tag:

/// <reference types="stripe-v3" />

This will attempt to get the type definition named stripe-v3 that you installed with NPM. If TypeScript has trouble finding it, you can use path instead:

/// <reference path="path/to/file" />

One Last Thing...

If you have a question or see a mistake, please comment below.

If you found this post helpful, please share it with others. It's the best thanks I can ask for & it gives me momentum to keep writing!

Matt Ferderer
Software Developer focused on making great user experiences. I enjoy learning, sharing & helping others make amazing things.
Let's Connect