Skip to content

Commit 1492e25

Browse files
committed
Define overloads
1 parent 2b88aeb commit 1492e25

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/lib/es5.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,3 +4577,23 @@ interface Date {
45774577
*/
45784578
toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
45794579
}
4580+
4581+
type Split<Source extends string, Separator extends string> = Source extends `${infer Left}${Separator}${infer Right}`
4582+
? [...(string extends Left ? string[] : [`${Left}`]), ...Split<Right, Separator>]
4583+
: Source extends ""
4584+
? Separator extends ""
4585+
? []
4586+
: [""]
4587+
: string extends Source
4588+
? string[]
4589+
: [Source];
4590+
4591+
interface String {
4592+
split<Source extends string, Separator extends string>(
4593+
this: Source,
4594+
separator: Separator,
4595+
limit?: undefined,
4596+
): Split<Source, Separator>;
4597+
4598+
split(separator: string | RegExp, limit: 0): [];
4599+
}

0 commit comments

Comments
 (0)