Microsoft/TypeScript

Gracefully handle template literal properties in the parser

Offen

#1.057 geöffnet am 04.11.2014

 (0 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)TypeScript (13.395 Forks)batch import
Domain: Error MessagesEffort: ModerateExperience EnhancementHelp Wanted

Repository-Metriken

Stars
 (108.860 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

var x = {
    a: "Hello"
    `b`: 123
}

Right now, the parser encounters the template string, decides it should bail out of object literal parsing, and we more or less recover thinking we have something like the following:

var x = ({ a: "Hello" } `b`) : 123 }

So we'll report an error on what we think is:

{ a: "Hello" } `b`
  • On the syntactic layer under ES5 mode, we'll say tagged templates are not supported unless in ES6.
  • On the semantic layer, we'll say { a: "Hello" } is not invokable.

Contributor Guide