Notes about String.replace
#54387
Labels
Bug
A bug in TypeScript
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
Help Wanted
You can do this
Milestone
(Moved from rom microsoft/TypeScript-DOM-lib-generator#1562)
I am using TypeScript 5.0.4.
I have noticed the typing of
String.replace
seem oddly convoluted.From
lib.es5.d.ts
:From
lib.es2015.symbol.wellknown.d.ts
:Like the first parameter is declared as an union, I would expect the second to be the same, at least in the
lib.es5
version.Notably, this makes the following code not compile:
By adding this into my declaration, the code works:
I cannot propose a solution other than my last hack, and of course the variants with
Symbol
would have to be taken into account. Please consider this just a note.See also this: #54223
The text was updated successfully, but these errors were encountered: