Skip to content

Fix Array interface (#10886) #11294

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

Closed
wants to merge 1 commit into from

Conversation

falsandtru
Copy link
Contributor

No description provided.

@RyanCavanaugh
Copy link
Member

What's the bug tracking this change?

@falsandtru
Copy link
Contributor Author

Fixes #10886

@falsandtru
Copy link
Contributor Author

Can someone review this?

@mhegazy
Copy link
Contributor

mhegazy commented Dec 30, 2016

sorry for the late reply. can you refresh this PR?

@falsandtru
Copy link
Contributor Author

done

@falsandtru falsandtru changed the title Fix the Array interface (#10886) Fix Array interface (#10886) Jan 18, 2017
@falsandtru
Copy link
Contributor Author

now updating

Copy link
Contributor Author

@falsandtru falsandtru left a comment

Choose a reason for hiding this comment

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

#10886 is not acceptable because of confusing with tuple types.

>regExpExecArrayValue.slice() : string[]
>regExpExecArrayValue.slice : (start?: number, end?: number) => string[]
>regExpExecArrayValue.slice() : RegExpExecArray
>regExpExecArrayValue.slice : (start?: number, end?: number) => RegExpExecArray
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrong, must return string[]. It can avoid by overloading in RegExpExecArray and RegExpMatchArray.

@@ -16,24 +16,24 @@ let t: [number, string] = [42, "hello"];
let a = t.slice();
>a : [number, string]
>t.slice() : [number, string]
>t.slice : { (start?: number, end?: number): (string | number)[]; (): [number, string]; }
>t.slice : { (start?: number, end?: number): [number, string]; (): [number, string]; }
>t : [number, string]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrong, concat and slice methods must not return this type when it is a tuple type. It cannot avoid.

@falsandtru
Copy link
Contributor Author

falsandtru commented Jan 19, 2017

improved. i tried to improve RegExp{Exec,Match}Array too,

interface RegExpMatchArray extends Array<string> {
    index?: number;
    input?: string;
    concat(): string[];
    slice(start?: 0): string[];
}

interface RegExpExecArray extends Array<string> {
    index: number;
    input: string;
    concat(): string[];
    slice(start?: 0): string[];
}

but i didn't complete that because it makes 637 errors. i cannot fix such a lot of errors.

@falsandtru
Copy link
Contributor Author

@mhegazy can you review before conflicting again?

@falsandtru
Copy link
Contributor Author

@mhegazy

@falsandtru
Copy link
Contributor Author

@RyanCavanaugh @ahejlsberg @DanielRosenwasser @sandersn @vladima @zhengbli @weswigham can you review instead of him?

@mhegazy
Copy link
Contributor

mhegazy commented May 23, 2017

Fixed by #12784

@mhegazy mhegazy closed this May 23, 2017
@falsandtru falsandtru deleted the lib.d.ts/array branch May 24, 2017 01:28
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
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.

4 participants