generator-angular2-library
generator-angular2-library copied to clipboard
Accessors are only available when targeting ECMAScript 5 and higher
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
Hi, this still errors for me. Your solutions seems to be working for now, so why is this issue closed?
I don't understand your comment. If my solution works for now, then what is the error you're getting?
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? :)
If you are saying that the generator has not yet been updated as per my recommendation above, then let's leave this open. Sorry.
@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!
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:

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

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 what do you mean , we have gulp build script , where should I write it ?
this problem bothers me a lot :(
@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"
@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
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
"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"
},