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

Add ES2017 Target #10768

Closed
yortus opened this issue Sep 8, 2016 · 20 comments
Closed

Add ES2017 Target #10768

yortus opened this issue Sep 8, 2016 · 20 comments
Labels
Committed The team has roadmapped this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@yortus
Copy link
Contributor

yortus commented Sep 8, 2016

This is a request to make "target": "es2017" a valid compiler option. There is a list of finished features for ES2017 (all stage 4) that can be found on the TC39 Finished Proposals page.

Note that TypeScript already supports "lib": ["es2017"] and includes lib.2017.d.ts, which declares the standard library features coming in ES2017, such as Object.values and Object.entries.

TypeScript also supports the two new syntactic features (async functions and trailing function commas), but with the current highest target (es6), these features are unconditionally downlevelled.

With an ES2017 target, async functions and trailing commas would be preserved in the transpiled JavaScript output, without downlevelling.

Async/await runtime support

Async functions are already implemented in both the V8 and ChakraCore runtimes. Node.js will support async/await natively (initially in v7.x with --harmony) when it updates to V8 5.4, expected by next month (i.e. October 2016).

Related issues

@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.1 milestone Sep 8, 2016
@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Committed The team has roadmapped this issue labels Sep 8, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Sep 8, 2016

A PR would be appreciated. Should be a small change.

@soft-labs
Copy link

Downlevel async/await is just a deal breaker for me right now. Is it happening anything about this issue?

@DanielRosenwasser DanielRosenwasser added the Good First Issue Well scoped, documented and has the green light label Sep 27, 2016
@DanielRosenwasser
Copy link
Member

@soft-labs downlevel async/await is available in our nightlies if you need. If your plan is to target ES201x to have Babel transform generators, then you can target ES2015 and do so.

@bootstraponline
Copy link
Contributor

@soft-labs downlevel async/await is available in our nightlies

The point of this issue is to output async/await without downleveling.

With an ES2017 target, async functions and trailing commas would be preserved in the transpiled JavaScript output, without downlevelling.

@soft-labs
Copy link

soft-labs commented Sep 27, 2016

@DanielRosenwasser Oh yes, I know. I need no transpilling at all, so I can use native chrome (is out now) and node with v8 5.4 native async/await implementation.

@pankleks
Copy link

I think everyone is waiting for TSC to have option to naively use async / await (without generation of __awaiter etc.).
Major browsers already support it, node should support it soon.
From functional perspective it does not bring anything extra, however debugging is nightmare with all of these __awaiter generated functions.

Any idea when this might be included in nighties?

@mhegazy mhegazy added the Help Wanted You can do this label Sep 27, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Sep 27, 2016

Any idea when this might be included in nighties?

We would be happy to accept a PR for this.

andrejbaran added a commit to andrejbaran/TypeScript that referenced this issue Oct 5, 2016
andrejbaran added a commit to andrejbaran/TypeScript that referenced this issue Oct 5, 2016
@pankleks
Copy link

Hi - trying to use es2017 target in tsconfig.json but I get:

error TS6046: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'

I'm using nightly: 2.1.0-dev.20161015

@yortus
Copy link
Contributor Author

yortus commented Oct 15, 2016

I think it was merged just after the cutoff time for the 20161015 nightly. Try tomorrow.

@pankleks
Copy link

Awesome!
Can't wait for this one:) thanks for the job you guys doing on that.

@imcotton
Copy link
Contributor

imcotton commented Nov 9, 2016

Does #11942 counts missing in ES2017 target?

@mhegazy
Copy link
Contributor

mhegazy commented Nov 10, 2016

7b9a42f adds a new --target esnext as well to get experimental features passed through.

@JD-Robbs
Copy link

Just wondering whether es2017 and esnext include the correct respective libs? I can see that tsc loads it in getDefaultLibFilename - but doesn't seem to work for me: the moment I change my target from es6 to es2017, my compiler is riddled with notices around console (TS2304:Cannot find name 'console'.) and some other standard types like XMLHttpRequest.

The code compiles fine - it's just that tsc complains and spits out loads of notices. Manually setting es2017 in the lib array doesn't make it go away.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 12, 2016

@JD-Robbs, it does not include the dom, can you file a new issue for that.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 12, 2016

specifying the lib explicitly in the tsconfig.json file should work though.

@JD-Robbs
Copy link

@mhegazy thank you very much indeed.

As you say, the following configuration works:

"target": "es2017",
"lib": [
  "es2017",
  "dom"
]

So - it's not an issue, I suppose.

@aluanhaddad
Copy link
Contributor

It still seems like it should work if it works for es2015. I added the lib option manually but it would be nice to not have to do that.

@noinkling
Copy link

noinkling commented Mar 14, 2017

The above still seems to be an issue. I can't find where in the codebase this is determined.

@nblavoie
Copy link

nblavoie commented Nov 6, 2017

Upgraded to Angular 5.0.0, still having the same issues described below :

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "commonjs",
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "preserveWhitespaces": false
  }
}

And running the command ng build output the following errors :

error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.
error TS5024: Compiler option 'lib' requires a value of type Array.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 6, 2017

@nblavoie this issue is closed almost a year ago. I do not think this is what you are looking for. You might have better luck sharing this on StackOverflow.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Committed The team has roadmapped this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests