I have the following webpack.config.js
var path = require(\"path\");
var webpack = require(\'webpack\');
module.exports = {
entry: {
\'ng2-auto-comple
https://stackoverflow.com/a/44800490/9690407
npm install typings -g
typings install
is deprecated in npm 5.6.0!
Instead use the npm install @types/core-js
syntax.
Just add:
"lib": ["es6"] // means at least ES6
Don't change target.
Target is used to tell Typescript into which version of ECMAScript to compile your .ts
files. Of course, you can change it, if the browser your application will be running in, will support that version of ECMAScript.
For example, I use "target": "es5"
and "lib": ["es6"]
.
Another reason could be:
That your .ts
file is not under "rootDir": "./YourFolder",
I'm using node.js v10.16.3.
The problem for me was that the typescript compiler was ignoring my tsconfig.json
file.
Three solutions worked for me:
tsc filename.ts --lib "es6", "dom"
when you compile the file@types/node
which will allow you to run tsc filename.ts
without errors.Since the answer directly to the OP has been answered already, I figured I would add what fixed it for me. My situation was slightly different in that I was not using WebPack and was getting these errors when trying to use tsc. The answer everyone else is giving (add "es6" to lib) did not resolve it for me. The problem for me was that I had v9.11.1 of node installed on my machine, but I had used npm to grab "@types/node", which got the most recent, v10+. Once I uninstalled that node typing and installed a specific v9 node typing file, this issue was resolved.
In my case I had to run:
npm install typings -g
typings install
That solved my problem.
for es6 use this
tsc filename.ts --lib es2015