-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptExperimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happensSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
This is a suggestion to change the signature declaration of Array sort in lib.d.ts from
sort(compareFn?: (a: T, b: T) => number): this;to
sort(this: string[], compareFn?: (a: string, b: string) => number): this;
sort(compareFn: (a: T, b: T) => number): this;i.e. make compareFn non-optional for non-string arrays. This would result in errors in cases such as
[2, 10].sort() // returns [10, 2], i.e. sorted lexicographically, which is very unintuitive.While this is strictly speaking a breaking change, it wouldn't be the first time the typings are stricter than the actually definitions.
zspitz, heejongahn, aluanhaddad, kitsonk, duanyao and 13 moreRudxain
Metadata
Metadata
Assignees
Labels
Domain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptExperimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happensSuggestionAn idea for TypeScriptAn idea for TypeScript