Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Jan 25, 2018

Noticed in #21413 that this function could be useful elsewhere, like createTextSpan is.

@ghost ghost requested a review from amcasey January 25, 2018 21:55
export function createTextChange(span: TextSpan, newText: string): TextChange;
export function createTextChange(start: number, length: number, newText: string): TextChange;
export function createTextChange(arg0: number | TextSpan, arg1: string | number, newText?: string): TextChange {
return typeof arg0 === "number" ? createTextChange(createTextSpan(arg0, arg1 as number), newText!) : { span: arg0, newText: arg1 as string };
Copy link
Member

Choose a reason for hiding this comment

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

why not have two separate functions instead of overload ? seems like the typeof check is unnecessary?

@ghost ghost merged commit cae4bc5 into master Jan 26, 2018
@ghost ghost deleted the createTextChange branch January 26, 2018 01:48
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 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.

2 participants