Microsoft/TypeScript

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

Open

#61 448 ouverte le 19 mars 2025

Voir sur GitHub
 (3 commentaires) (0 réactions) (1 assigné)TypeScript (6 726 forks)batch import
Domain: lib.d.tsFix AvailableHelp WantedPossible Improvement

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

⚙ 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

Guide contributeur