ts-loader icon indicating copy to clipboard operation
ts-loader copied to clipboard

Accessors are only available when targeting ECMAScript 5 and higher

Open deryl27 opened this issue 11 years ago • 13 comments

How to provide target to ES5 while using ts-loader ??

deryl27 avatar Jul 27 '15 16:07 deryl27

By using a tsconfig.json file.

jbrantly avatar Jul 27 '15 16:07 jbrantly

You would want something like this:

{
  "compilerOptions": {
    "target": "es5"
  }
  "files": []
}

jbrantly avatar Jul 27 '15 16:07 jbrantly

@jbrantly Thanks It works

deryl27 avatar Jul 27 '15 17:07 deryl27

Thank you. This is currently the highest google result for the error message.

For me, this migration guide for angular-cli is missing "target": "es5" in tsconfig.json

jakeNiemiec avatar Mar 02 '17 20:03 jakeNiemiec

@jakeNiemiec you are right that the main (in root folder) tsconfig.json does not contain the "target": "es5", but cli have specific derived tsconfig.app.json and tsconfig.spec.json configs specified under src which both contained the target.

BTW I had to specify the "target": "es5" in the root to make it work in VSCode and remove the specific target lines from the derived once.

Thanks for the hint anyway.

attilacsanyi avatar Mar 07 '17 14:03 attilacsanyi

Hi, I had same problem after updating angular-cli as jakeNiemiec. In my case I only needed to add the target line in tsconfig.json in the root folder and restart VSC.

dmijatovic avatar Mar 08 '17 19:03 dmijatovic

If you are dealing with just a single file and not a project set --target ES2016. For eg

$ tsc --target ES2016 /filepath/filename.ts --watch

ref

SOHELAHMED7 avatar Sep 30 '17 11:09 SOHELAHMED7

Very Helpful

Gideon877 avatar Oct 02 '17 09:10 Gideon877

nice :D

jorgematheus avatar Feb 27 '18 18:02 jorgematheus

Thank you @SOHELAHMED7

mcrisostomo avatar May 02 '18 14:05 mcrisostomo

if you input a file to tsc in command line it ignore the tsconfig.json and you need to insert a flag for each config you want( e.g --target ES2016) . but if you not input ant file in the command line and just add the file in the tsconfig.json tsc will read the config file stackoverflow ts docs

yoni333 avatar Dec 26 '18 16:12 yoni333

@SOHELAHMED7 Thank you :)

joonseolee avatar Aug 20 '19 11:08 joonseolee

Thanks @SOHELAHMED7

ilmoralito avatar Apr 07 '20 04:04 ilmoralito