Skip to content

Remove unnecessary *OrUndefined calls #18889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Oct 3, 2017
Merged

Remove unnecessary *OrUndefined calls #18889

2 commits merged into from
Oct 3, 2017

Conversation

ghost
Copy link

@ghost ghost commented Oct 2, 2017

The range array should be non-empty; we are treating accesses to firstOrUndefined and lastOrUndefined as certainly defined, so it makes sense to just use range[0] and last(range).

@ghost ghost requested a review from amcasey October 2, 2017 17:53
@@ -469,7 +469,7 @@ namespace ts.refactor.extractSymbol {
* depending on what's in the extracted body.
*/
function collectEnclosingScopes(range: TargetRange): Scope[] | undefined {
let current: Node = isReadonlyArray(range.range) ? firstOrUndefined(range.range) : range.range;
let current: Node = isReadonlyArray(range.range) ? range.range[0] : range.range;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be tempted to add (and call) a first helper for symmetry.

@ghost ghost force-pushed the orUndefined branch from dff4522 to 187a97e Compare October 2, 2017 18:14
@ghost ghost merged commit b111493 into master Oct 3, 2017
@ghost ghost deleted the orUndefined branch October 3, 2017 17:24
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant