Repository navigation
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/esrap/c/2729d072b2afcc75ce648da0af983338e91254feOpen in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
|
1028d1b to
ef24689
Compare
…nst token matching
`import type {} from` was written as one string since sveltejs#219, so with tokens
neither the keyword nor the braces could match; write them one token at a time.
Add tests for the comment handling the token matcher relies on: a comment whose
text is a bracket (`/* ( */`, `// )`, a commented-out block, a comment line
that is a lone `}`) must not be consumed as the next source token, and the
real brackets after it must still map exactly.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ef24689 to
2729d07
Compare
|
uhhhhh this auto-closed when i merged |
Stacked on #235 (base:
tokens-alt). Two small things carried over from #213 that the token-matching approach needs.Empty type-only import. #219 prints
import type {} fromas a single string, andcontext.writeonly maps a write whose trimmed text is exactly one token, so with tokens neithertypenor the braces matched. Written one token at a time now. Two test cases: braces ofimport type /* before */ { /* inside */ } from 'module'and thetypekeyword ofimport /* c */ type {} from 'm'.Guard for comments that look like tokens. The matcher relies on
write_commentnever handing it a bare bracket, which #235 arranges by writing a one-line comment's delimiters together with its text. Nothing tested that, so I added the cases where it can go wrong: a comment is flushed afterenter(node), so a comment whose text is the next node's own opening bracket is the one that can be consumed. Against the pre-#235 comment writer,const o = /* { */ { a: 1 };loses the mapping of its}; with #235 all of these pass:/* { */,/* [ */,/* ( */)(or{, before an arrow or a block// ), and a commented-out block containing}linesEach case checks that every bracket outside comments in the output maps to the matching source bracket.
No changeset: #235's covers it. 522 tests pass, lint clean.
🤖 Generated with Claude Code