Skip to content

fix: don't inject attributes into TypeScript generics - #1

Merged
Peyton-Spencer merged 1 commit into
mainfrom
fix/generics-regex
Feb 8, 2026
Merged

fix: don't inject attributes into TypeScript generics#1
Peyton-Spencer merged 1 commit into
mainfrom
fix/generics-regex

Conversation

@Peyton-Spencer

Copy link
Copy Markdown
Contributor

Summary

  • The JSX regex was matching < in TypeScript generics (Accessor<boolean>, createContext<Type>, createStore<Store>) as JSX opening tags, injecting data-solid-source attributes inside type annotations and causing parse errors
  • Fix: added negative lookbehind (?<!\w) to the regex — JSX < is preceded by whitespace/operators, generics < is preceded by an identifier character
  • Added 2 test cases covering generics-only files and mixed generics+JSX files

Test plan

  • All 48 tests pass (2 new)
  • Build succeeds with clean DTS
  • Verify in ditto-app: bun run dev no longer throws parse errors

🤖 Generated with Claude Code

The JSX regex was matching `<` in TypeScript generics like
`Accessor<boolean>`, `createContext<Type>`, and `createStore<Store>`
as if they were JSX opening tags.

Add a negative lookbehind `(?<!\w)` so the `<` must NOT be preceded
by a word character. In JSX, `<` follows whitespace/operators/punctuation,
but in generics it follows an identifier.

Fixes parse errors when used with real-world SolidJS apps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Peyton-Spencer
Peyton-Spencer merged commit 100070d into main Feb 8, 2026
1 check passed
@Peyton-Spencer
Peyton-Spencer deleted the fix/generics-regex branch February 9, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant