Microsoft/TypeScript

Gracefully handle template literal properties in the parser

Open

#1 057 ouverte le 4 nov. 2014

Voir sur GitHub
 (0 commentaires) (2 réactions) (0 assignés)TypeScript (6 726 forks)batch import
Domain: Error MessagesEffort: ModerateExperience EnhancementHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

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.

Guide contributeur