Generate TypeScript Declaration Files for JavaScript Files

Here’s the way you can generate TypeScript declaration files for your JavaScript project

The JavaScript logo with an arrow pointing towards the TypeScript logo
  • With pnpm: pnpm i -D typescript
  • With npm: npm i -D typescript
  • With yarn: yarn add typescript -D
"scripts": {
"prepare": "tsc --declaration --emitDeclarationOnly --allowJs index.js"
},
  • With pnpm: pnpm prepare or pnpm run prepare
  • With npm: npm run prepare
  • With yarn: yarn run prepare

--

--

I am a developer experienced in Python, JavaScript, Vue.js, Swift, and Git. I write about content that I find interesting or useful to share with the world.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
H. Kamran

I am a developer experienced in Python, JavaScript, Vue.js, Swift, and Git. I write about content that I find interesting or useful to share with the world.