microsoft / microsoft/TypeScript
Unoptimized destructuring compilation
Open
Nobody has claimed this yet.
Help Wanted
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 2.0
Code
// source ts code
let i = 1000;
while (i--) {
let [a, b, c] = [1, 2, 3];
}
Expected behavior:
// compiled by babel
var i = 1000;
while (i--) {
var a = 1;
var b = 2;
var c = 3;
}
Actual behavior:
// compiled by tsc
var i = 1000;
while (i--) {
var _a = [1, 2, 3], a = _a[0], b = _a[1], c = _a[2];
}
On each iteration tsc creates new unnecessary array _a.
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 2.0 example from the issue and compare its generated JavaScript with the expected Babel output. Trace the destructuring compilation path responsible for the temporary _a array. Done means the loop no longer creates an unnecessary array on each iteration while preserving destructuring behavior.
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