#1529·ripple

[Bug]: @tsrx/core's error codes are final: new codes for its errors, and Ripple's own errors have none

Author: leonidazCreated Sep 27, 2026Updated Sep 28, 2026

[!WARNING] Wait for the @tsrx/core release that includes tsrx-org/tsrx#888. The codes below come with it. Switching the tests to the DIAGNOSTIC_CODES constants (#1524) can be done now.

Issue Category

Other (upgrading @tsrx/core)

Bug Description

@tsrx/core now gives every error a code (tsrx-org/tsrx#843, merged in tsrx-org/tsrx#888). The TSRX specification lists every code in its appendix B, "Error codes":

  • A mistake TypeScript also reports gets TypeScript's own code.
  • A mistake only TSRX reports gets a TSRX code: TSRX1xxx for markup, TSRX2xxx for template rules, TSRX3xxx for style blocks and CSS, and TSRX4xxx for everything else.

What that means for Ripple:

1. DIAGNOSTIC_CODES keeps its names; the values change. Ripple's compiler compares with the constant (style-scopes.js#L573), which keeps working. Five tests compare literal strings (#1524):

Constant Before After
STYLE_APPLY_VALUE tsrx-style-apply-value TSRX3001
STYLE_APPLY_TARGET tsrx-style-apply-target TSRX3002
STYLE_APPLY_BEFORE_DECLARATION tsrx-style-apply-before-declaration TSRX3003
STYLE_STANDALONE_OUTSIDE_TEMPLATE tsrx-style-standalone-outside-template TSRX3008
STYLE_STANDALONE_NEEDS_FRAGMENT tsrx-style-standalone-needs-fragment TSRX3009
CSS_GLOBAL_PLACEMENT tsrx-css-global-placement TSRX3011

JSX_EXPRESSION_VALUE is removed, since no error used it; Ripple doesn't use it.

2. Core's errors that had no code now have one. For example:

tsrx
export function App() @{
	@for (let i = 0; i < 3; i++) {
		<li />
	}
}
before  code: undefined   For loops are not supported in TSRX templates. Use for...of instead.
after   code: TSRX2015    For loops are not supported in TSRX templates. Use for...of instead.

That error comes from validateTsrxUnsupportedLoopStatement, which Ripple calls. Parser errors now carry TypeScript's code: '}' expected. is TS1005, and a redeclared name is TS2300.

3. Two kinds of parser messages now use TypeScript's wording:

  • An import or export inside a block: acorn's 'import' and 'export' may only appear at the top level is now TypeScript's error for each kind, such as TS1232 (An import declaration can only be used at the top level of a namespace or module.) or TS1184 (Modifiers cannot appear here.).
  • using or await using in a for…in head: now TS1493 and TS1494.

Nothing in Ripple matches these messages today (checked at 83ed5615).

4. Ripple's own errors have no code. Ripple's analyzer raises 36 distinct messages through error(). Core's table gives only one of them a code, await is not allowed inside components (TSRX2021). The other 35 have none. For example:

tsrx
export function App() @{
	<div onClick={} />
}
code: undefined   attributes must only be assigned a non-empty expression

The specification says every error a conforming implementation reports carries a code. A suggestion, for Ripple to decide:

  • Where Ripple's error duplicates one of core's, use core's message. error() then gives it core's code with no code argument, and the two report the same mistake the same way. For example, an empty attribute expression is TypeScript's TS17000 (JSX attributes must only be assigned a non-empty 'expression'.).
  • Give the rules only Ripple has their own codes, such as the module server rules, track outside a reactive context, and the <head> rules. The prefix and numbering are Ripple's choice (for example RIPPLE1001), passed through error()'s code argument.

References

  • tsrx-org/tsrx#843: the code scheme; tsrx-org/tsrx#888: the change.
  • #1524: switch the tests to the constants.
  • @tsrx/mcp maps the old tsrx-* codes to the new ones, so a Ripple release still on the old codes shows the new ones there.