Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provide ES5 target #311

Open
nehaagrawal opened this issue May 3, 2017 · 5 comments
Open

Please provide ES5 target #311

nehaagrawal opened this issue May 3, 2017 · 5 comments
Assignees
Milestone

Comments

@nehaagrawal
Copy link

We are transpiling our project to ES5 but antrl4ts is using ES6. I have read that it's incompatible and we can't use it till you provide the ES5 version . Is there a way around?

Thanks!

@BurtHarris
Copy link
Collaborator

Can you be more specific about your intended target environment. What is it you're sayin ES6 target code is incompatible with?

@BurtHarris BurtHarris added this to the vNext milestone May 18, 2017
@BurtHarris
Copy link
Collaborator

BurtHarris commented Jun 30, 2017

Here's the TypeScript issue that previously blocked a simple implementation of this feature request: microsoft/TypeScript#3164. Basically the capability to use JavaScript for...of loops to iterate our emulated Java collection was limited to ES2015 or greater.

This has gotten some recent work by the TypeScript team, with PR microsoft/TypeScript#12346. So we should be able to support this now. @nehaagrawal, @sdcb. @michael-bowen-sc: Please provide details on scenario/target environment you are interested in. I don't want to do the work to fix this one case and find you're still not getting what you want.

@nehaagrawal
Copy link
Author

Thanks BurtHarris for replying. There are multiple reasons we need ES5

  1. We are using angular-cli for web development and there is no support for uglifyjs for ES6.The only way for us to make it work is to set target to ES5 in tsconfg.json
    ERROR with UglifyJs when building npm start build:prod PatrickJS/PatrickJS-starter#853
    https://stackoverflow.com/questions/41865131/ng-serve-prod-for-ng-cli-results-in-uglifyjs-syntaxerror-unexpected-token-na/42087500

  2. The other reason is since many browsers still don't support ES6 100% , my team is not comfortable using ES6.

@BurtHarris
Copy link
Collaborator

More notes on a possible solution: The new feature in TypeScript 2.3 that may enable this is the --downlevelIteration compiler option. See https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript.

@TristanGaydon
Copy link

@nehaagrawal not sure if this will help, but I was able to work around this issue using Babel to transpile the antlr4ts ES6 to ES5.

We use Webpack2 and I was able to get it working with a config like this;

rules: [
{
    test: /\.js$/,
    exclude: /(node_modules(?!(\/|\\)antlr4ts)|scripts|libs)/,
    use: {
        loader: 'babel-loader',
        options: {
            presets: ['env']
        }
    }
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants