Tsallaka zuwa abun ciki
Justice Tech School

Declaration Files and Globals

.d.ts files describe the types of JavaScript libraries. @types packages from DefinitelyTyped supply them. declare tells the compiler about things that exist elsewhere.

Example
// npm install --save-dev @types/node
// global.d.ts
// declare const APP_VERSION: string;
// declare module "*.svg" { const url: string; export default url; }
console.log("d.ts files carry types only");

Result

d.ts files carry types only

Exercise

Install types for a library.

npm i -D @types/

Quiz Test

What is a .d.ts file?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.