Some JS libraries include typing file so they work with Typescript project without additional work.
But in case a library does not have a declaration file, you need to install the type package
separately.
yarn add --dev @types/package-name
Ambient declaration is a way to define types
, variables
, functions
, or other entities
without providing their actual implementation.
--dev
--dev
is indicating a dev dependency installation.
Dev dependency are things that are not direct dependencies for your project.
This is a good place to install typescript types declarations because they're only used in the build process.
.d.ts
).d.ts
file is a declaration file.
// js file: util.js function sayHello(name) { console.log("Hello, " + name); } // d.ts file: util.d.ts declare function sayHello(name: string): void;