Skip to main content

Effortless Type Definitions: Unlock the Power of TypeSync

Firefly (from Honkai Star Rail) staring at you
Last updated: July 30, 2024

If you’re using TypeScript in your projects and working with a bunch of plain JavaScript libraries, installing the declaration files for these libraries can definitely be a headache, especially if you’re dealing with a large-scale project with a significant number of plain JavaScript libraries.

The package we’re talking about today solves this problem entirely and takes away all that headache.

The package is called typesync. All you need to do is install it in your project and start using it.

First, you’ll install the package using any package manager you prefer, whether it’s npm, yarn, or even pnpm.

Terminal
# npm
npm install typesync
# yarn
yarn add typesync
#pnpm
pnpm add typesync

Next, you’ll execute the package in your terminal:

npm
# npm
npm typesync
# yarn
yarn typesync
#pnpm
pnpm typesync

Here’s what the package does:

First, it scans your entire project to identify which plain JavaScript libraries are installed and which ones have type definitions available and which ones don’t.

Secondly, it updates the package.json file with all this information but does not install any of the packages.

package.json
{
"name": "typesync",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@types/cors": "~2.8.17",
"@types/express": "~4.17.21",
"nodemon": "^3.1.4",
"typescript": "^5.5.4",
"typesync": "^0.13.0"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.19.2"
}
}

Therefore, in the final step, you’ll manually install these packages:

Terminal
npm install

And with that, you’ve installed all the type definitions with just 3 commands.

Finally you can descover full typesync docs

📜 typesync docs