microsoft / microsoft/TypeScript

Gracefully handle template literal properties in the parser

Open
#1,057 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: Error Messages Effort: Moderate Experience Enhancement Help Wanted
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

``` TypeScript
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:

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

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

``` TypeScript
{ 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the parser's object-literal handling and reproduce the shown template-literal property case under ES5 and ES6 modes. Trace how the parser recovers at the template string and compare the resulting syntactic and semantic diagnostics. Done means this malformed or unsupported construct receives appropriate diagnostics without being misread as a tagged call.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.