Microsoft/TypeScript
在 GitHub 查看Add types for `String.{matchAll,replaceAll}` with a well known symbol
Open
#61,448 建立於 2025年3月19日
Domain: lib.d.tsFix AvailableHelp WantedPossible Improvement
倉庫指標
- Star
- (48,455 star)
- PR 合併指標
- (平均合併 6天 17小時) (30 天內合併 9 個 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