question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ES3 is a poor default for typescript

See original GitHub issue

Search Terms

defaults, ecmascript

Suggestion

The latest available typescript typescript@3.7.2 produces a bunch of unnecessary errors by targeting a very old version of JavaScript:

Error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.

Typescript should update the default language version to something more reasonable.

Use Cases

A user install typescript. They compile a project using tsc which will fail in most cases. The users discovers that TypeScript targets a 21 year old version of JavaScript by default. They update their compiler options to support and 11 year old version of JavaScript at minimum.

Examples

tsc somefile.ts working without errors.

Checklist

My suggestion meets these guidelines:

  • This wouldn’t be a breaking change in existing TypeScript/JavaScript code
  • This wouldn’t change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript’s Design Goals.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
mikemaccanacommented, Jan 14, 2020

Just a note that I’m unsubscribing from this bug as I’m tired of the sarcasm and trolling.

7reactions
RyanCavanaughcommented, Jan 14, 2020

A few points

  • Inconvenience or annoyance doesn’t clearly outweigh someone else’s runtime behavior getting broken during a compiler update. The asymmetry of impact here is very large.
  • The set of users who would get hurt worst by this aren’t the ones who are reading the issue tracker
  • We really, really think everyone should be using a tsconfig.json at this point, and tsc --init does default to ES5
  • I don’t think this will never change, but we’d probably do an all-at-once update to all of the default commandline options at some point (moduleResolution, strictFunctionTypes, strictNullChecks, and a few others come to mind as things that should have different defaults “in the future”). Maybe once every 10 years would be a reasonable cadence for that (TypeScript 5.0?)
  • Twitter polls about what people are choosing to currently target is not what’s under consideration here. A poll from the original position would be “Do you want to have your program break during some future compiler update so that someone else feels less inconvenienced about the no-config-file behavior of TypeScript?” which I think would have very different results.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Should I use TypeScript or ES6 to compile to es3/5 [closed]
Am I correct in assuming that I will be able to switch from a typescript codebase to a pure ES6 codebase when it...
Read more >
Which version of EcmaScript should I use in the TypeScript ...
Which version of EcmaScript should I use in the TypeScript configuration. TypeScript allows converting most of the ES next features to ES3, ES5...
Read more >
Default Exports in JavaScript Modules Are Terrible - Reddit
TypeScript has always allowed you to use modern JavaScript features and supported automatic down level compilation to ES3 with a simple ...
Read more >
The Great CoffeeScript to Typescript Migration of 2017
There are companies that pretty much waste millions on poorly ... I was a big fan of coffescript, it was way better than...
Read more >
grunt-ts - npm
src, target, string or string[] - glob of TypeScript files to compile. target, option, 'es5' (default), 'es3' , or 'es6' - targeted ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found