Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a local typescript declaration file for an installed module?

Tags:

When I installed a non popular module that doesn't have a published type declaration under @types namespace, I'm stuck. I know how to write a declaration file, but I don't know how to make typescript compiler aware of it. The typescript documentation doesn't mention how to do it. The docs only mention to search for type declaration and if not found, publish a new one but doesn't mention how to do it without publishing.

So, say I installed a package named xyz and I know the public api that it exposes. Then, I write a type declaration file that matches the exposed api. Then, How to make typescript compiler aware of it?

like image 962
Mas Bagol Avatar asked Apr 25 '18 10:04

Mas Bagol


1 Answers

Just add a <module-name>.d.ts file to your project, and TypeScript should become aware of it automatically. You don't need to import it or anything, just to be in the folders processed by TypeScript

like image 194
Oscar Paz Avatar answered Sep 28 '22 18:09

Oscar Paz