问题
In this article on distributing an angular library the author says that it's a good idea to not touch the dom directly because it makes the component unusable inside web workers.
Should we thus leave dom
out of the typescript lib
compiler option or are there certain use cases where we absolutely need it? Here's an example with dom included:
"compilerOptions": {
"target": "es5",
"module": "es2015",
"lib": ["es2015", "dom"]
},
The sample tsconfig.json compiler options includes dom
...
回答1:
It doesn't compile without "dom". The reason is that the angular libraries export methods/classes that consume/return "dom" types. So when you go to compile against angular, your compilation fails because it cannot find the types.
回答2:
typescript lib setting dom be included when developing an angular 4
Yes.
Reason
Angular is designed for the DOM.
来源:https://stackoverflow.com/questions/43786728/should-the-typescript-lib-setting-dom-be-included-when-developing-an-angular-4-c