镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Start using ES5 functionality in tsc #10125

Description

Note that this issue is not about dropping support for --target es3.

This came up in a meeting today. Given that tsc.exe now uses ChakraCore to run tsc.js, it's not clear how much value users are getting in being able to run TypeScript on ES3 runtimes.

Reasons we'd do this include

  • Being able to use ES5 array methods such as map, filter, reduceLeft, some, and every.
  • Being able to create empty objects as maps with Object.create(null) to avoid hasOwnProperty calls for every lookup.
  • Using get-accessors for lazily computing position information.
  • Being able to use JSON.stringify.

Activity

  1. changed the title [-]Consider requiring an ES5 runtime for TypeScript[/-] [+]Consider requiring an ES5 runtime for running tsc[/+] on Aug 3, 2016
  2. changed the title [-]Consider requiring an ES5 runtime for running tsc[/-] [+]Start using ES5 functionality in tsc[/+] on Aug 3, 2016
  3. DanielRosenwasser commented on Aug 3, 2016

    @DanielRosenwasser
    MemberAuthor

    Gotta make the title less scary-sounding. 😃

  4. RyanCavanaugh commented on Aug 4, 2016

    @RyanCavanaugh
    Member

    /cc mihailik who we remember was doing something with TS on ES3

  5. mihailik commented on Aug 4, 2016

    @mihailik
    Contributor

    Thanks Ryan Cavanaugh (@RyanCavanaugh) -- the reasons, costs and benefits suggest this should not be done as of yet. There are two parts to this issue: work to be done and resulting effect.


    **THE EFFECT** (just looking at the goals stated) seems to be at least superficial, or may be even negative. How so?

    Today operations like map, forEach are funneled through a selective subset of APIs. ES5 opens up more ways to do the same thing (some of them obscure or just bizarre). In practice this will lead to a code quality dip, even if migration is factored out.

    You would spend time and cognitive effort finding, explaining and checking the safe ES5 subset is used as an ongoing extra "tax".

    There are positives of course: tsc.js size would decrease, performance might improve, in certain parts syntax would be more familiar to the non-core contributors. A bit of marketing boost too, as always with getting new features.

    Again, looking at the goals stated, there is no killer feature in ES5 that would simplify or boost code:

    • forEach and map are already callable through simple wrappers,
    • map operations are wrapped too -- so Object.create can be feature-detected and handled at wrapper level,
    • getters are marginally cooler than method calls, but performance/readability-wise are just the same.

    **THE COST OF IMPLEMENTATION** depends on the strategy.

    Could be a risky big-bang with whole team's work disrupted during widespread changes Lots of upfront cost, tailing over the coming week or two.

    Or it could be the same cost spread across months while old and new approaches coexist. This migratory state is likely to mess up debugging experience and performance metrics quite a bit.

  6. weswigham commented on Aug 4, 2016

    @weswigham
    Member

    mihailik That's your evaluation of the upsides and downsides for us.... but would this change affect you? Would us moving to writing our compiler with ES5 functions break you? (It would mean that the compiler could no longer be run on ES3 runtimes)

  7. mihailik commented on Aug 4, 2016

    @mihailik
    Contributor

    Yes, because I cannot polyfill getters on ES3. Everything else is a manageable.

    If it comes to that, I'll have to peg TS to a pre-ES5 version, and stick to it :-(

  8. RyanCavanaugh commented on Oct 31, 2016

    @RyanCavanaugh
    Member

    We're doing this already with Object.create(null). ES3 support is now effectively dropped.

  9. nym commented on Dec 27, 2016

    @nym

    This affects some companies running ES3 native implementations. It may sound like ES3 is extremely old with ES7 on the horizon, but being able to compile TS to ES3 is a very big deal for some large companies.

  10. vladima commented on Dec 27, 2016

    @vladima
    Contributor

    Tom Longson (@nym) we are not dropping support for ES3 as compilation target. Question raised in this thread is whether it is possible to run TypeScript compiler itself in ES3 environment and currently the answer is no

  11. nym commented on Jan 3, 2017

    @nym

    Vladimir Matveev (@vladima) thanks for the clarification.

  12. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeCommittedThe team has roadmapped this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions