fix(typecheck): resolve UI imports as component contracts
Quality / quality (ubuntu-latest) (push) Failing after 22s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 22:07:37 +05:30
parent 5de792f359
commit 082da38f67
4 changed files with 19 additions and 2 deletions
+1 -1
View File
@@ -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",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@wrnexus/typecheck",
"version": "0.8.8",
"version": "0.8.9",
"type": "module",
"main": "src/index.ts",
"exports": {
+3
View File
@@ -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/") &&
@@ -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 { <Card><PreferenceSwitcher /></Card> }
}`,
{ appRoot: root, filePath },
);
expect(diagnostics.some((item) => item.code === "WRN-TYPE-2305")).toBe(false);
}, 15_000);