jnsmalm
jnsmalm

Reputation: 348

Compile Typescript without DOM declarations

I would like to compile TypeScript without including the DOM declarations. The environment I'm working with doesn't have any DOM, only pure ES6 features. For example I want to have my own Window class, but right now it conflicts with the Window class coming from DOM lib file. I only want to include ES6 declarations when compiling, can this be done?

Upvotes: 0

Views: 201

Answers (1)

Nitzan Tomer
Nitzan Tomer

Reputation: 164237

Typescript 2 introduced a new compiler options called lib.
Using that option you can now:

specify a list of built-in API declaration groups that you can chose to include in your project

I haven't had the change to use it, but according to the docs:

you can exclude declarations you do not want to include in your project, e.g. DOM if you are working on a node project using --lib es5,es6.

So should be something like:

tsc --lib es5,es6

Or:

"compilerOptions": {
    "lib": ["es5", "es6"]
}

Upvotes: 1

Related Questions