Microsoft/TypeScript

Gracefully handle template literal properties in the parser

开放

#1,057 创建于 2014年11月4日

 (0 条评论) (2 个反应) (0 位负责人)TypeScript (13,395 个派生)batch import
Domain: Error MessagesEffort: ModerateExperience EnhancementHelp Wanted

仓库指标

星标
 (108,860 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南