Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include lib.es2015.core.d.ts in tsconfig.json?

I'm writing Angular 2 Universal app, so I don't want any DOM types. But I want to compile all files in dir, so setting "file" in tsconfig.json is not acceptable.

like image 211
OwnageIsMagic Avatar asked Jul 22 '16 22:07

OwnageIsMagic


People also ask

What is Lib in Tsconfig json?

TypeScript includes a default set of type definitions for built-in JS APIs (like Math ), as well as type definitions for things found in browser environments (like document ).

Where do I put Tsconfig json?

The tsconfig. json is generally put in the root folder of the project.

Does TSC use Tsconfig?

Running tsc locally will compile the closest project defined by a tsconfig. json , you can compile a set of TypeScript files by passing in a glob of files you want.


2 Answers

But I want to compile all files in dir, so setting "file"

file has no effect on lib.d.ts anyways.

lib.es2015.core.d.ts in tsconfig.json

If you want core you would do:

"compilerOptions": {
    "target": "es5",
    "lib": ["es5","es2015.core"]
}

More

More : https://github.com/basarat/typescript-book/blob/master/docs/types/lib.d.ts.md#lib-option

However you most likely want to include all of es6 and not just core or array etc.:

"compilerOptions": {
    "target": "es5",
    "lib": ["es6"]
}
like image 126
basarat Avatar answered Oct 13 '22 18:10

basarat


typescript@>2.0

"compilerOptions": {
    ...
    "lib": ["es5", "es6", "es6.array"]
}
like image 1
OwnageIsMagic Avatar answered Oct 13 '22 17:10

OwnageIsMagic