简体   繁体   中英

Can changing TypeScript compilerOptions->lib conflict with NPM Packages or Dependencies

I have a question about the compilerOptions->lib property in tsconfig.json .

Situation is I'm working on a Firebase Cloud Functions project written in TypeScript and I need the method Array.prototype.includes() . But I was unable to build because includes() was not supported, a quick Google search showed I only had to change lib from ES6 to ES2016 which changes the version of Ecmascript.

My question is. Does changing the lib property do anything besides giving me newer/more functionality?

I'm worried if it somehow might conflict with Firebase Cloud Functions or the NodeJS version I'm using or NPM packages/dependencies.

No the lib flag doesn't change the output of the Typescript compiler, the target flag does that.

lib simply includes the typings of the library versions you specify in the compilation process, so that compiler won't complain. (These typings could be found under node_modules\\typescript\\lib)

If your target runtime doesn't support the functions you use (includes() in this case), its your responsibility to provide it using a polyfill. Typescript doesn't actually include the library for you in the compiled output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM