#1524·ripple

[错误]: 样式诊断测试将 TSRX 错误代码作为字面串进行比较,而在下一个 @tsrx/core 中,这些代码会发生变化

作者: leonidaz创建于 2026年9月27日更新于 2026年9月27日
标签bug

[!IMPORTANT] Two parts, with different timing.

  • Switch the tests to the DIAGNOSTIC_CODES constants: can be done now. The constants exist in today's @tsrx/core and 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/core release 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/core is giving every error a standard code (tsrx-org/tsrx#843): TypeScript's own code for a mistake TypeScript also reports, such as TS1029, and a TSRX code for TSRX's own errors, such as TSRX1001. Today's string codes, like tsrx-style-apply-target, become TSRX codes. The constant names in DIAGNOSTIC_CODES stay the same; only their values change.

Ripple's compiler already uses the constant (style-scopes.js#L573), which keeps working. Five assertions in tests/style-diagnostics.test.js compare the codes as literal strings, and those will fail after the upgrade:

javascript
// Today: fails once the code becomes a TSRX code
expect(error_codes(source)).toEqual(['tsrx-style-apply-target']);
javascript
// 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_DECLARATION
L41 'tsrx-style-apply-target' DIAGNOSTIC_CODES.STYLE_APPLY_TARGET
L51 'tsrx-style-apply-value' DIAGNOSTIC_CODES.STYLE_APPLY_VALUE
L60 'tsrx-style-standalone-needs-fragment' DIAGNOSTIC_CODES.STYLE_STANDALONE_NEEDS_FRAGMENT
L69 'tsrx-style-standalone-outside-template' DIAGNOSTIC_CODES.STYLE_STANDALONE_OUTSIDE_TEMPLATE

Errors that have no code …

内容来源: Ripple-TS/ripple