microsoft / microsoft/TypeScript
Gracefully handle template literal properties in the parser
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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