From 06d7d0e966c5c847ba91cf585bcb47fc1f37f013 Mon Sep 17 00:00:00 2001 From: Nathan Nguyen <146415969+NathanDrake2406@users.noreply.github.com> Date: Sun, 17 May 2026 00:34:39 +1000 Subject: [PATCH] fix: constrain root tsconfig project scope The root TypeScript project previously relied on TypeScript's implicit include set, which pulled independent workspace app files and nested package build output into root tooling. That made standard tsc checks report app-local alias and Workers type errors through the vinext package project. Add an explicit include list for root-owned config files, vinext source, and root tests. Cover the boundary with a regression test that asserts independent apps, generated package output, and local worktree directories stay outside the parsed root project. --- tests/root-tsconfig.test.ts | 40 +++++++++++++++++++++++++++++++++++++ tsconfig.json | 8 ++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/root-tsconfig.test.ts diff --git a/tests/root-tsconfig.test.ts b/tests/root-tsconfig.test.ts new file mode 100644 index 000000000..c0e532075 --- /dev/null +++ b/tests/root-tsconfig.test.ts @@ -0,0 +1,40 @@ +import path from "node:path"; +import ts from "typescript"; +import { describe, expect, it } from "vite-plus/test"; + +const repoRoot = path.resolve(import.meta.dirname, ".."); +const rootTsconfig = path.join(repoRoot, "tsconfig.json"); + +function loadRootTsconfigFileNames(): string[] { + const config = ts.readConfigFile(rootTsconfig, (fileName) => ts.sys.readFile(fileName)); + if (config.error) { + throw new Error(ts.flattenDiagnosticMessageText(config.error.messageText, "\n")); + } + + const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, repoRoot); + if (parsed.errors.length > 0) { + throw new Error( + parsed.errors + .map((error) => ts.flattenDiagnosticMessageText(error.messageText, "\n")) + .join("\n"), + ); + } + + return parsed.fileNames.map((fileName) => + path.relative(repoRoot, fileName).replaceAll(path.sep, "/"), + ); +} + +describe("root tsconfig scope", () => { + it("keeps independent app files and package build output outside the root project", () => { + const fileNames = loadRootTsconfigFileNames(); + + expect(fileNames).toContain("packages/vinext/src/index.ts"); + expect(fileNames).toContain("tests/root-tsconfig.test.ts"); + expect(fileNames).toContain("vite.config.ts"); + expect(fileNames.some((fileName) => fileName.startsWith("apps/"))).toBe(false); + expect(fileNames.some((fileName) => fileName.startsWith("packages/vinext/dist/"))).toBe(false); + expect(fileNames.some((fileName) => fileName.startsWith(".claude/"))).toBe(false); + expect(fileNames.some((fileName) => fileName.startsWith(".worktrees/"))).toBe(false); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 9c8b4ae82..2879f6869 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,5 +14,13 @@ "vinext/shims/*": ["./packages/vinext/src/shims/*"] } }, + "include": [ + "*.ts", + "*.tsx", + "packages/vinext/src/**/*.ts", + "packages/vinext/src/**/*.tsx", + "tests/**/*.ts", + "tests/**/*.tsx" + ], "exclude": ["node_modules", "dist", "fixtures", "tests/fixtures", "benchmarks", "examples"] }