Comments (20)
I have the same problem.
target: "es3"
is supposed to be the default option. When I try to set target
to either es3, es5 or es6 I get the errors @unional has mentioned. When I remove this option from config, module generates without errors (es3 version?). A bit weird though, looking for your help.
from plugin-typescript.
can you try setting it to 0 (the enum value for "es3" - ts.ScriptTarget.ES3)? I will try and look into this more later.
from plugin-typescript.
When having target: 0
it compiles without errors. Thank you, please find out why it doesn't work with listed options.
upd: By the way, setting it to 1
doesn't really change anything :)
from plugin-typescript.
Update, setting target: 0
also has no effect. It does not tell tsc to transpile it to es3. I tested with:
var x = [];
x.forEach(function (y) {
console.log(y);
});
it remains in the transpiled file.
from plugin-typescript.
I have released 2.0.4 with a fix for this. You will need to set target to 0 due to microsoft/TypeScript#3976 / systemjs/systemjs#608 but the output will now be es3.
from plugin-typescript.
Thanks @frankwallis . I have tested it with 2.0.4 and now with target: 0
the plugin.js
transpiled file is correct:
function translate(load) {
logger.debug("systemjs translating " + load.address);
However, the typescript file is still not transpiled to es3:
var x = [];
x.forEach(function (y) {
console.log(y);
});
still remain as Array.forEach
in the transpiled file.
from plugin-typescript.
I don't believe that TypeScript converts forEach into plain for loops when targetting ES3, you are expected to provide a polyfill. Alternatively you can use a for...of loop:
for (let y of x) {
console.log(y);
}
from plugin-typescript.
Oh, I didn't know that... I put that in just trying to validate it is indeed transpile to es3. Do you have any suggestion? I'll validate it and close this issue. :)
from plugin-typescript.
The one I put in the tests is that it removes trailing commas from object literals in ES3 mode, but not in ES5 mode.
from plugin-typescript.
Saw it. Thanks!
from plugin-typescript.
@frankwallis Sorry to bother, but what about es5/es6 target, is it possible?
from plugin-typescript.
Yes - es5 target is the default target, and es6 should work but I haven't tried it.
from plugin-typescript.
When I try to set any of them except 0, I get an error:
SystemJS Error: SyntaxError: evalmachine.<anonymous>:11
logger.debug(`systemjs translating ${ + load.address);
^
Unexpected token ILLEGAL
Evaluating file:///Users/vadzim/DEV/Projects/WKL/wk.ui/jspm_packages/github/frankwallis/[email protected]/lib/plugin.js
Error loading file:///Users/vadzim/DEV/Projects/WKL/wk.ui/jspm_packages/github/frankwallis/[email protected]/lib/plugin.js from file:///Users/vadzim/DEV/Projects/WKL/wk.ui/jspm_packages/github/frankwallis/[email protected]
The generated content of a small module comes out in 12000 lines of code. What am I doing wrong?
from plugin-typescript.
You do need to use 1 for "es5" and 2 for "es6"?
from plugin-typescript.
When I set either 0
or 1
I get an identical output. Setting 2
ends up with error: [Error: Debug Failure. False expression: ] and no more details.
More details about loading config and building:
var builder = new Builder();
builder.reset();
builder
.loadConfig(config.systemJsConfig)
.then(function() {
return builder.buildSFX(file.path);
})
.catch(function(err) {
plugins.util.log('SystemJS Error:', err);
next(err, null);
});
Sorry, but I have no idea what I am doing wrong. Really grateful for your help.
from plugin-typescript.
What are you trying to achieve? Just leave the option out and let it default to es5?
from plugin-typescript.
That's what I'm doing, but at least 0
doesn't change the output and 2
doesn't work.
from plugin-typescript.
The output of es5 and es3 is identical for most code. There are subtle differences such as in es3 mode trailing commas are removed from object literals and in es5 mode they are not.
from plugin-typescript.
Don't get me wrong, I am just trying to say – setting 1
or 2
fails out with an error, maybe you could drop a list of really available options to Readme inside the plugin?
from plugin-typescript.
I think 1 works, 2 is failing because TypeScript does not handle target="es6" with module="system". Next time I make changes I will add a comment and throw a better error if this happens.
from plugin-typescript.
Related Issues (20)
- 7.x branch not on npm? HOT 1
- Unexpected export encountered on abstract classes HOT 3
- defaulting to tsconfig: true HOT 6
- tslib_1.__metadata is not a function HOT 2
- Plugin-Typescript doesn't completely strip out Interface import/exports which breaks rollup. HOT 12
- no such file or directory: `plugin-typescript/lib.js` HOT 7
- exports is not defined HOT 3
- js error when loading - cannot read property 'length' of undefined HOT 6
- ENOENT: no such file or directory HOT 1
- Systemjs builder output not working as expected HOT 2
- No console output from Typescript compilation errors HOT 1
- Lookup error at node v8.1.2 npm 5.0.3 HOT 2
- Support for "module": "ESNext" HOT 1
- Not compatible with Typescript 2.6.x package HOT 1
- Getting "Cannot read property 'map' of undefined" HOT 1
- Is it possible to load global script? HOT 6
- tsconfig extends HOT 3
- Error: require is not defined HOT 8
- Does not work with typescript 2.9.1 and above HOT 1
- Getting errors during npm install
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugin-typescript.