Microsoft/TypeScript

TS1518 depends on operand order in negated v-mode class unions

開放

#63,718 建立於 2026年8月4日

 (1 則留言) (0 個反應) (0 位負責人)TypeScript (13,395 個分叉)batch import
BugDomain: ParserHelp Wanted

倉庫指標

星標
 (108,860 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

🔎 Search Terms

TS1518, RegExp v flag, MayContainStrings, negated character class, ClassUnion, operand order, q{}

🕗 Version & Regression Information

Occurs in every version tested: 7.0.2 and 7.1.0-dev.20260804.1 (nightly). I searched open and closed issues.

💻 Code

const a = /[^\q{xy}b]/v; // TS1518
const b = /[^b\q{xy}]/v; // no error

🙁 Actual behavior

TS1518 only considers the first union operand. The second pattern is accepted but is invalid JavaScript.

🙂 Expected behavior

Both patterns report TS1518: MayContainStrings is true when any union operand may match a string.

貢獻者指南