diff --git a/src/vite.ts b/src/vite.ts
index 71f25ab..fe85aa9 100644
--- a/src/vite.ts
+++ b/src/vite.ts
@@ -36,12 +36,16 @@ import type { SolidGrabPluginOptions } from "./types.js";
*
| | <= | <<
+ * Accessor
| createContext (TypeScript generics)
+ *
+ * The negative lookbehind (?)/g;
+ /(?)/g;
/**
* Matches component-style names: PascalCase or contains a dot (Foo.Bar).
diff --git a/tests/vite-plugin.test.ts b/tests/vite-plugin.test.ts
index c107076..5ff1fd0 100644
--- a/tests/vite-plugin.test.ts
+++ b/tests/vite-plugin.test.ts
@@ -80,6 +80,38 @@ describe("transform", () => {
expect(result).toBeNull();
});
+ test("does not inject into TypeScript generics", () => {
+ const plugin = createPlugin();
+ const code = [
+ `const x: Accessor = () => true;`,
+ `const ctx = createContext(null);`,
+ `const [store, setStore] = createStore({});`,
+ `function useFoo(a: string, b: Accessor) {}`,
+ `return useDittoQuery({});`,
+ ].join("\n");
+ const result = (plugin as any).transform(code, "/project/src/hooks.tsx");
+
+ // No JSX in this code — should return null (no changes)
+ expect(result).toBeNull();
+ });
+
+ test("injects into JSX but not generics in the same file", () => {
+ const plugin = createPlugin();
+ const code = [
+ `function App() {`,
+ ` const x: Accessor = () => true;`,
+ ` return hello
;`,
+ `}`,
+ ].join("\n");
+ const result = (plugin as any).transform(code, "/project/src/App.tsx");
+
+ expect(result).not.toBeNull();
+ expect(result.code).toContain('data-solid-source=');
+ // The generic should be untouched
+ expect(result.code).toContain("Accessor");
+ expect(result.code).not.toContain("Accessor {
const plugin = createPlugin({ jsxLocation: false });
const code = `function App() {\n return hello
;\n}`;