Code Monkey home page Code Monkey logo

Comments (20)

rootical avatar rootical commented on June 3, 2024

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.

frankwallis avatar frankwallis commented on June 3, 2024

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.

rootical avatar rootical commented on June 3, 2024

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.

unional avatar unional commented on June 3, 2024

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.

frankwallis avatar frankwallis commented on June 3, 2024

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.

unional avatar unional commented on June 3, 2024

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.

frankwallis avatar frankwallis commented on June 3, 2024

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.

unional avatar unional commented on June 3, 2024

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.

frankwallis avatar frankwallis commented on June 3, 2024

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.

unional avatar unional commented on June 3, 2024

Saw it. Thanks!

from plugin-typescript.

rootical avatar rootical commented on June 3, 2024

@frankwallis Sorry to bother, but what about es5/es6 target, is it possible?

from plugin-typescript.

frankwallis avatar frankwallis commented on June 3, 2024

Yes - es5 target is the default target, and es6 should work but I haven't tried it.

from plugin-typescript.

rootical avatar rootical commented on June 3, 2024

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.

frankwallis avatar frankwallis commented on June 3, 2024

You do need to use 1 for "es5" and 2 for "es6"?

from plugin-typescript.

rootical avatar rootical commented on June 3, 2024

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.

frankwallis avatar frankwallis commented on June 3, 2024

What are you trying to achieve? Just leave the option out and let it default to es5?

from plugin-typescript.

rootical avatar rootical commented on June 3, 2024

That's what I'm doing, but at least 0 doesn't change the output and 2 doesn't work.

from plugin-typescript.

frankwallis avatar frankwallis commented on June 3, 2024

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.

rootical avatar rootical commented on June 3, 2024

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.

frankwallis avatar frankwallis commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.