Skip to content

Playground: red squigglies on Promises in ES5 target #704

Closed
@Zlatkovsky

Description

@Zlatkovsky

One thing I’ve found really insightful in the past is being able to target ES5 in TS Playground, to see all of the state-machine code that gets generated.

In the recent(ish) upgrade to TS Playground, however, that scenario is moderately broken. As soon as I set the target option to ES5, I get a bunch of red squigglies, saying:

  • 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.
  • An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your --lib option.(2705)

image

Is there any way to still support this scenario? It seems silly to have all these red squigglies, when the code does in fact run perfectly fine in Chrome.

I could set the target to ES2015, but then I don’t get the same type of output (i.e., I see a generator function rather than the full gory details of the ES5 implementation; whereas it’s the latter that I want, screenshotted below). So what I really want is an ES5 output, but with a lib option saying that Promises should be supported.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    PlaygroundIssues that affect the Playground

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions