Microsoft/TypeScript

Add types for `String.{matchAll,replaceAll}` with a well known symbol

Open

#61.448 aperta il 19 mar 2025

Vedi su GitHub
 (3 commenti) (0 reazioni) (1 assegnatario)TypeScript (6726 fork)batch import
Domain: lib.d.tsFix AvailableHelp WantedPossible Improvement

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

⚙ Compilation target

es2022

⚙ Library

ES2023

Missing / Incorrect Definition

Definitions for String.{matchAll,replaceAll} with an object that implements [Symbol.matchAll]/[Symbol.replace], rather than a pure RegExp.

Sample Code

const someObjectThatImplementsTheSymbols = ...; // e.g. https://github.com/segevfiner/node-pcre2
"foo".matchAll(someObjectThatImplementsTheSymbols);
"foo".replaceAll(someObjectThatImplementsTheSymbols, "bar");

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll

Guida contributor