Repository navigation
Conversation
…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>
|
Install the latest version of pnpm add https://pkg.svelte.dev/esrap/c/d37105232f9164191d0d7afc87456ff951cb5d72Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: d371052 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
3 of 45 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #235, which landed before this could be folded in (it was #236, stacked on
tokens-alt, and closed automatically when that branch was deleted). Same code, rebased onmain.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 withtokensneithertypenor the braces matched. Written one token at a time now. Two test cases: the 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 this adds 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 the current writer 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.
Validation:
pnpm test— 525 tests passedpnpm lint— passedpnpm check— passed🤖 Generated with Claude Code