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" />

Matt Ferderer

Full Stack Software Developer focused on JavaScript and C#. Love to share & help others make amazing things. Have a project you need help on? Let's talk!