Categories
TypeScript Answers

How to set the TypeScript definitions for all projects files?

Spread the love

Sometimes, we want to set the TypeScript definitions for all projects files.

In this article, we’ll look at how to set the TypeScript definitions for all projects files.

How to set the TypeScript definitions for all projects files?

To set the TypeScript definitions for all projects files, we can add entries to the compilerOptions.lib property in tsconfig.json.

For instance, we write

{
  //...
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "lib": ["es5", "es2015.promise", "dom"]
  },
  "include": ["src/**/*.ts"]
  //...
}

to add the compilerOptions.lib option and set it to ["es5", "es2015.promise", "dom"] into tsconfig.json

This will make all the variables provided by the browser and the JavaScript core library of the given versions available in our projects.

Conclusion

To set the TypeScript definitions for all projects files, we can add entries to the compilerOptions.lib property in tsconfig.json.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *