microsoft / microsoft/TypeScript
Allow to extract code containing `return` statement if it's at the end of a function
Open
Nobody has claimed this yet.
Domain: LS: Refactorings
Experience Enhancement
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: nightly (2.6.0-dev.20170904)
Code
export function f() {
if (1) {
return 1;
}
...do stuff...
}
export function g() {
...do stuff...
if (1) {
return 1;
}
}
Expected behavior:
Able to extract the if statement out of g.
Not able to extract from f because that would change the control flow.
Actual behavior:
Not able to extract in either case. (But somehow it works in #18091?)
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 extraction behavior with the two TypeScript examples in the issue and compare it with the behavior referenced in issue #18091. The work is done when extraction succeeds for the trailing return in g while remaining unavailable for the earlier return in f.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100