Microsoft/TypeScript

Gracefully handle template literal properties in the parser

Open

#1.057 aberto em 4 de nov. de 2014

Ver no GitHub
 (0 comments) (2 reactions) (0 assignees)TypeScript (6.726 forks)batch import
Domain: Error MessagesEffort: ModerateExperience EnhancementHelp Wanted

Métricas do repositório

Stars
 (48.455 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)

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.

Guia do colaborador