diff --git a/bun.lock b/bun.lock index c3cf9e68..aed076a1 100644 --- a/bun.lock +++ b/bun.lock @@ -609,7 +609,7 @@ }, "packages/typecheck": { "name": "@wrnexus/typecheck", - "version": "0.8.8", + "version": "0.8.9", "dependencies": { "@wrnexus/syntax": "workspace:*", "typescript": "^5.5.0", diff --git a/packages/typecheck/package.json b/packages/typecheck/package.json index cb28ec7f..99188994 100644 --- a/packages/typecheck/package.json +++ b/packages/typecheck/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/typecheck", - "version": "0.8.8", + "version": "0.8.9", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/typecheck/src/index.ts b/packages/typecheck/src/index.ts index aebf6701..fdc6e00d 100644 --- a/packages/typecheck/src/index.ts +++ b/packages/typecheck/src/index.ts @@ -153,6 +153,9 @@ function retainedImports(ast: PageAst): string { return ast.structuredImports .filter((entry) => { if (entry.source.endsWith(".wrn")) return false; + // UI components are framework artifacts, not JavaScript exports. Their + // contracts are loaded from component-reference.json below. + if (!entry.typeOnly && entry.source === "@wrnexus/ui") return false; if (entry.typeOnly) return true; return ( !entry.source.startsWith("@/components/") && diff --git a/packages/typecheck/test/imports-and-components.test.ts b/packages/typecheck/test/imports-and-components.test.ts index 0abd2863..d0392255 100644 --- a/packages/typecheck/test/imports-and-components.test.ts +++ b/packages/typecheck/test/imports-and-components.test.ts @@ -83,3 +83,17 @@ page Home { expect(diagnostics.some((item) => item.code === "WRN-TYPE-1389")).toBe(false); expect(diagnostics.some((item) => item.code === "WRN-TYPE-1005")).toBe(false); }, 15_000); + +test("does not treat UI component imports as JavaScript exports", () => { + const root = fixture(); + const filePath = join(root, "app", "pages", "home.wrn"); + const diagnostics = checkWrnSource( + `import { Card, PreferenceSwitcher } from "@wrnexus/ui" +page Home { + view { } +}`, + { appRoot: root, filePath }, + ); + + expect(diagnostics.some((item) => item.code === "WRN-TYPE-2305")).toBe(false); +}, 15_000);