generator-angular2-library icon indicating copy to clipboard operation
generator-angular2-library copied to clipboard

Accessors are only available when targeting ECMAScript 5 and higher

Open broweratcognitecdotcom opened this issue 8 years ago • 14 comments

From .src/tsconfig.es5.json:

// This file is used by ngc to create the files in the build directory { "compilerOptions": { "declaration": true, "module": "es2015", "target": "es5", "baseUrl": ".", . . .

./tsconfig.json doesn't contain the "target" property.

The solution is to add it.

Robert

broweratcognitecdotcom avatar Sep 21 '17 07:09 broweratcognitecdotcom

Hi, this still errors for me. Your solutions seems to be working for now, so why is this issue closed?

StefanoChiodino avatar Jan 30 '18 15:01 StefanoChiodino

I don't understand your comment. If my solution works for now, then what is the error you're getting?

broweratcognitecdotcom avatar Jan 30 '18 15:01 broweratcognitecdotcom

I get the error out of the box. Shouldn't this be fixed so that when generated it works, rather than having to search on closed github issues to find a workaround? :)

StefanoChiodino avatar Jan 30 '18 15:01 StefanoChiodino

If you are saying that the generator has not yet been updated as per my recommendation above, then let's leave this open. Sorry.

broweratcognitecdotcom avatar Jan 30 '18 16:01 broweratcognitecdotcom

@StefanoChiodino Are you using the latest version of the generator? The target property is part of the src/tsconfig.es5.json file: https://github.com/jvandemo/generator-angular2-library/blob/master/generators/app/templates/src/_tsconfig.es5.json#L5.

If not, can you please update to the latest version and check if everything is okay? Thanks!

jvandemo avatar Feb 04 '18 21:02 jvandemo

I had pulled it on a new computer. However I just tried again from yet another computer and I have the same problem.

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./src",
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "rootDir": "./src",
    "lib": [
      "es2015",
      "dom"
    ],
    "skipLibCheck": true,
    "types": []
  }
}

The build seems to be working, however vscode complains: screenshot

StefanoChiodino avatar Feb 05 '18 06:02 StefanoChiodino

Any progress on this issue? I just tried today and there is a problem,

SteveStrong avatar Apr 08 '18 01:04 SteveStrong

image

SteveStrong avatar Apr 08 '18 01:04 SteveStrong

try using this command in the terminal while compiling: "tsc.exe --target ES5 yourfilename.ts"

In place of "ES5" we can even write 'ES6 or higher'

nikhilavula avatar Sep 19 '18 05:09 nikhilavula

@nikhilavula what do you mean , we have gulp build script , where should I write it ?

this problem bothers me a lot :(

chesminsky avatar Sep 21 '18 14:09 chesminsky

@chesminsky write it in a terminal: -If your using a VSCode, use the built-in terminal while compiling. -You can even use a Command prompt to compile.

Instead of "tsc.exe filename.ts" use "tsc.exe --target ES5 filename.ts"

nikhilavula avatar Sep 21 '18 17:09 nikhilavula

@broweratcognitecdotcom @StefanoChiodino @jvandemo i solved it by renaming tsconfig.es5.json to tsconfig.json
and in gulpfile accordingly seems like vscode linter ignores tsconfig.es5.json such filename

chesminsky avatar Sep 26 '18 13:09 chesminsky

Solution : compile : tsc --target ES5 fileName.ts run : node fileName.js

Example : compile : tsc --target ES5 demo.ts run : node demo.js OR(combined comand ) tsc --target ES5 demo.ts && node demo.js

Himanshukmr avatar Apr 30 '20 07:04 Himanshukmr

 "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "incremental": true,
    "esModuleInterop": true,
    "target": "es2020",  <-- THE SOLUTION FOR ME
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },

Chasty avatar Mar 30 '23 18:03 Chasty