microsoft / microsoft/TypeScript
Verbose computed property transpilation
Open
Nobody has claimed this yet.
Domain: API: Transforms
Help Wanted
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 2.7.0-dev.201xxxxx
Search Terms:
Code
const p1 = 0;
const p2 = 1;
class A {
[p1] = 0;
[p2]() {}
}
Expected behavior:
const p1 = 0;
const p2 = 1;
class A {
constructor() {
this[p1] = 0;
}
[p2]() { }
}
Actual behavior:
const p1 = 0;
const p2 = 1;
class A {
constructor() {
this[_a] = 0;
}
[(_a = p1, p2)]() { }
}
var _a;
Playground Link:
Related Issues:
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 by reproducing the TypeScript example in the issue and compare its emitted JavaScript with the expected output. Trace computed property handling during transpilation, then add coverage for the class field and computed method case; done means the unnecessary temporary variable and comma expression are no longer emitted.
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