fix(typecheck): resolve UI imports as component contracts
This commit is contained in:
@@ -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,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/typecheck",
|
||||
"version": "0.8.8",
|
||||
"version": "0.8.9",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user