[错误]: 样式诊断测试将 TSRX 错误代码作为字面串进行比较,而在下一个 @tsrx/core 中,这些代码会发生变化
作者: leonidaz创建于 2026年9月27日更新于 2026年9月27日
标签bug
[!IMPORTANT] Two parts, with different timing.
- Switch the tests to the
DIAGNOSTIC_CODESconstants: can be done now. The constants exist in today's@tsrx/coreand keep their names in the next release, so the tests pass before and after the upgrade.- Anything that needs the new codes themselves: wait for the
@tsrx/corerelease that includes tsrx-org/tsrx#843. The codes will be listed in the TSRX specification.Issue Category
Other (preparing for the next
@tsrx/core)Bug Description
@tsrx/coreis giving every error a standard code (tsrx-org/tsrx#843): TypeScript's own code for a mistake TypeScript also reports, such asTS1029, and aTSRXcode for TSRX's own errors, such asTSRX1001. Today's string codes, liketsrx-style-apply-target, becomeTSRXcodes. The constant names inDIAGNOSTIC_CODESstay the same; only their values change.Ripple's compiler already uses the constant (
style-scopes.js#L573), which keeps working. Five assertions intests/style-diagnostics.test.jscompare the codes as literal strings, and those will fail after the upgrade:// Today: fails once the code becomes a TSRX code expect(error_codes(source)).toEqual(['tsrx-style-apply-target']);// Instead: passes with today's @tsrx/core and the next import { DIAGNOSTIC_CODES } from '@tsrx/core'; expect(error_codes(source)).toEqual([DIAGNOSTIC_CODES.STYLE_APPLY_TARGET]);The five, at
83ed5615:
Line Literal Constant L27 'tsrx-style-apply-before-declaration'DIAGNOSTIC_CODES.STYLE_APPLY_BEFORE_DECLARATIONL41 'tsrx-style-apply-target'DIAGNOSTIC_CODES.STYLE_APPLY_TARGETL51 'tsrx-style-apply-value'DIAGNOSTIC_CODES.STYLE_APPLY_VALUEL60 'tsrx-style-standalone-needs-fragment'DIAGNOSTIC_CODES.STYLE_STANDALONE_NEEDS_FRAGMENTL69 'tsrx-style-standalone-outside-template'DIAGNOSTIC_CODES.STYLE_STANDALONE_OUTSIDE_TEMPLATEErrors that have no code …
内容来源: Ripple-TS/ripple