Repository navigation
Adopt esrap 2.3.11+ sourcemaps: pass tokens, drop boundaryTokens and the bracket guess once esrap #212/#213 land #235
Copy link
Copy link
Open
Labels
Description
esrap's sourcemap model changed in 2.3.10 and 2.3.11 (sveltejs/esrap#192, #198, #199), and two follow-up PRs are open (sveltejs/esrap#212 node starts printed inline, #213 tokens option). This tracks the @tsrx/core changes to adopt them and delete the mapping workarounds. octane uses createJsxTransform from @tsrx/core, so it is covered by the same changes.
Status on esrap 2.3.11 (verified by running compile_to_volar_mappings with esrap redirected)
Nothing crashes: the _ override in packages/tsrx/src/transform/jsx/helpers.js delegates to esrap's root visitor, so the per-node mappings from #198 come through. The only mappings lost versus 2.3.2 are the lexer function keyword tokens after async (esrap no longer maps a second keyword). boundaryTokens: true is ignored since 2.3.11.
Once sveltejs/esrap#213 ships (tokens option)
tsx_with_ts_locationsinhelpers.js: dropboundaryTokens, pass the parser's tokens astokens.parse/index.jsalready collectsonTokenoutput forkeywordTokens; keep the full token array (or the delimiters) for the volar print. Updatetypes/parse.d.tsESRapTSOptions, which declares neitherboundaryTokensnortokens.segments.jsset_bracket_computed_mapping: stop guessing[/]atkey.loc ± 1and stop skipping the mapping when the guess is absent (6c34d7d). With tokens both brackets have exact source positions and esrap maps them, so the mapping can be built from the real positions and computed-key diagnostics (TS2416, TS2464, TS1166, TS1170) are reported again, including[ key ], comments inside the brackets and multi-line keys.segments.jsIfStatementconsequent/alternate{/}tokens (column ± 1): the braces areBlockStatementboundaries that esrap maps; use the node positions.- The shared
source-mappings.jsfixtures that say "skipped, not fatal" for computed keys and spans ending at a closing paren or bracket can assert exact mappings instead.
Once sveltejs/esrap#212 ships
LOCATION_WRAPPED_NODE_TYPESandTOOLING_LOCATION_WRAPPED_NODE_TYPESinhelpers.jsare mostly redundant with fix: resolve relative url() in style blocks and reject @import (#153) #198 (every visited node's start and end is mapped). Trim them to what esrap still cannot map: template-literal backticks are covered, JSX<><//>are not, generic-argument<>are not.- The
importstatement token and the trailing;fudge insegments.jscan be rechecked against the node mappings. case/default,catchandfor-head declarations are mapped by esrap; nothing to add on our side, but the fallthrough (TS7029) and modifier diagnostics can now be asserted intype-diagnostics.js.
Still open on the esrap side
- Second keywords (
functionafterasync,else,finally,whileindo … while) are not mapped; keep the lexer keyword tokens until esrap locates them fromtokens. - Sourcemaps: parentheses added by the printer have no location sveltejs/esrap#211 (parentheses added by the printer have no location), [Bug]: React static JSX hoisting reads a class before initialization #204 (comments after decorators), fix(prettier): keep the definite-assignment assertion on class fields (#202) #205 (typed identifier's end mapping) are tracked there.
Activity