Skip to content

Commit edec1eb

Browse files
committed
Add generic type parameter to startsWith/endsWith
1 parent 0f3d0e0 commit edec1eb

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/lib/es2015.core.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ interface String {
401401
* same as the corresponding elements of this object (converted to a String) starting at
402402
* endPosition – length(this). Otherwise returns false.
403403
*/
404+
endsWith<T extends string>(searchString: T): this is `${string}${T}`;
404405
endsWith(searchString: string, endPosition?: number): boolean;
405406

406407
/**
@@ -431,6 +432,7 @@ interface String {
431432
* same as the corresponding elements of this object (converted to a String) starting at
432433
* position. Otherwise returns false.
433434
*/
435+
startsWith<T extends string>(searchString: T, position?: 0): this is `${T}${string}`;
434436
startsWith(searchString: string, position?: number): boolean;
435437

436438
/**

tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
113113
fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'.
114114
~~~~~~~
115115
!!! error TS2551: Property 'toFixed' does not exist on type 'string'. Did you mean 'fixed'?
116-
!!! related TS2728 /.ts/lib.es2015.core.d.ts:485:5: 'fixed' is declared here.
116+
!!! related TS2728 /.ts/lib.es2015.core.d.ts:487:5: 'fixed' is declared here.
117117
fn5 `${ (n) => n.substr(0) }`;
118118

119119

0 commit comments

Comments
 (0)