microsoft / microsoft/TypeScript
Feature Request: Line Breaks in Assignments in Compiled Javascript
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
One of typescript's key advantages over Babel (at least as far as I'm concerned), is the readability of its compiled javascript. It is so readable, in fact, that I often use typescript for non-typescript projects, and just submit the compiled javascript. One issue that often arises, however, is that the compiled javascript will not match style rules in these javascript projects. One style rule is to have each assignment on its own line. Typescript generally does this, except when destructuring. It would be extremely valuable to be able to specify a compiler option for assignmentsOnNewLine which would add line breaks after each assignment.
For example, the following typescript code:
const aVeryLargeObject = {
firstValue: 1,
secondValue: 2,
thirdValue: 3,
fourthValue: 4
};
const {firstValue, secondValue, thirdValue, fourthValue} = aVeryLargeObject;
Produces the following javascript:
var aVeryLargeObject = {
firstValue: 1,
secondValue: 2,
thirdValue: 3,
fourthValue: 4
};
var firstValue = aVeryLargeObject.firstValue, secondValue = aVeryLargeObject.secondValue, thirdValue = aVeryLargeObject.thirdValue, fourthValue = aVeryLargeObject.fourthValue;
If this feature was implemented it should produce the following javascript:
var aVeryLargeObject = {
firstValue: 1,
secondValue: 2,
thirdValue: 3,
fourthValue: 4
};
var firstValue = aVeryLargeObject.firstValue,
secondValue = aVeryLargeObject.secondValue,
thirdValue = aVeryLargeObject.thirdValue,
fourthValue = aVeryLargeObject.fourthValue;
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
Use the issue's TypeScript and JavaScript examples as the behavioral reference, then locate the compiler's destructuring emission and compiler-option definitions. Done means the option is supported and the emitted assignments use the requested line breaks, with tests covering the shown output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100