[Bug]: Style diagnostic tests compare TSRX error codes as literal strings, which change in the next @tsrx/core
[!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/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:
// 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_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 today, such as the return/break/continue template errors and TypeScript-style mistakes, get one in that release. If Ripple shows or matches error codes anywhere else, such as editor diagnostics or docs, check those too.
Reproduction Steps
Search Ripple for literal tsrx-… error codes: git grep -n "'tsrx-style\|'tsrx-css\|'tsrx-jsx\|'tsrx-unclosed\|'tsrx-mismatched" -- packages.
Environment
- Ripple
mainat83ed5615,@tsrx/core0.3.3 (pinned)
Additional Context
- tsrx-org/tsrx#843: the decision and the code scheme.
- The same change for Octane: octanejs/octane#1337; for
@tsrx/oxc: tsrx-org/oxc#117.
Checklist
- I've searched for existing issues
Source: Ripple-TS/ripple