You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/stream.ts:7:43 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'string | ((substring: string, ...args: any[]) => string)' is not assignable to parameter of type '(substring: string, ...args: any[]) => string'.
Type 'string' is not assignable to type '(substring: string, ...args: any[]) => string'.
7 return this.name.replace(searchValue, replaceValueOrReplacer);
~~~~~~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.es5.d.ts:454:5
454 replace(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last overload is declared here.
The text was updated successfully, but these errors were encountered:
lib Update Request
The type definitions for
String.replace
andString.replaceAll
are written using overloads. Should they not be written with union type parameters?Overloads give problems when creating wrapper functions for
String.replace
; see example below.This has already been proposed in this comment in another issue but I cannot find a follow-up issue or discussion.
The documentation describes a similar problem and also advises to prefer union types, when possible.
Sample Code
The text was updated successfully, but these errors were encountered: