Microsoft/TypeScript

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

開放

#61,448 建立於 2025年3月19日

 (3 則留言) (0 個反應) (1 位負責人)TypeScript (13,395 個分叉)batch import
Domain: lib.d.tsHelp WantedPossible Improvement

倉庫指標

星標
 (108,860 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

⚙ 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

貢獻者指南