Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

ci: run tsrs type checks across the workspace (#44610)

Stephen Zhouae6319f7576b
diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml
index 7d4f7da0d98..29483f9f2ba 100644
--- a/.github/workflows/style.yml
+++ b/.github/workflows/style.yml
@@ -239,6 +239,9 @@ jobs:
- name: Static check
run: vp run -w check
+ - name: Type check with tsrs
+ run: vp run -r type-check
+
- name: Tooling rule tests
run: vp run @dify/tooling#test run
diff --git a/package.json b/package.json
index 569f8e9dc8b..8669e42e951 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,8 @@
"lint:tailwind:fix": "TAILWIND_CANONICAL_CLASSES=true vp lint --fix web packages/dify-ui",
"lint:eslint": "eslint --concurrency=auto",
"lint:eslint:fix": "eslint --fix --concurrency=auto",
- "lint:eslint:quiet": "eslint --quiet --concurrency=auto"
+ "lint:eslint:quiet": "eslint --quiet --concurrency=auto",
+ "type-check": "tsrs --noEmit"
},
"devDependencies": {
"@dify/tooling": "workspace:*",
@@ -29,6 +30,7 @@
"concurrently": "catalog:",
"eslint": "catalog:",
"knip": "catalog:",
+ "tsrs": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
"vite-plus": "catalog:"
diff --git a/packages/tooling/README.md b/packages/tooling/README.md
index 546a01dec65..4bbbcfcffa0 100644
--- a/packages/tooling/README.md
+++ b/packages/tooling/README.md
@@ -1,6 +1,6 @@
# Repository Tooling
-Vite+ provides the primary static check through `vp check`, which combines Oxfmt formatting, Oxlint code-quality rules, and TypeScript diagnostics. The root command also runs ESLint for non-code file types that Oxlint cannot parse.
+Vite+ provides the primary static check through `vp check`, which combines Oxfmt formatting and Oxlint code-quality rules. TypeScript diagnostics run separately through each package's `type-check` script using tsrs. The root command also runs ESLint for non-code file types that Oxlint cannot parse.
`@dify/tooling` is the private workspace package that owns JS/TS linting, formatting,
custom rules, and dead-code tooling. Edit the implementations here:
@@ -41,8 +41,8 @@ vp run -w check:fix
CI and local development use the same root `vite.config.ts` configuration.
-The root `check` script delegates to the `check:cached` Vite Task. Formatting, linting,
-and type checking reuse successful results when their tracked inputs are unchanged.
+The root `check` script delegates to the `check:cached` Vite Task. Formatting and linting
+reuse successful results when their tracked inputs are unchanged.
`CI`, `NODE_ENV`, and `TAILWIND_CANONICAL_CLASSES` are included in the cache key;
check results never restore files into the working tree. Fix commands remain uncached.
To force a fresh check, run `vp run -w --no-cache check`.
@@ -54,7 +54,7 @@ time saved in the Vite Task summary.
Reuse successful checks for the same final changes. Repeat or expand checks only when subsequent edits, failures, or unresolved concerns require it.
-To narrow formatting and linting, pass paths directly to Vite+. Type checking remains repository-wide:
+To narrow formatting and linting, pass paths directly to Vite+:
```sh
vp check web/app/components packages/dify-ui/src/button
@@ -85,7 +85,7 @@ vp run -w lint:eslint package.json pnpm-workspace.yaml web/docs
vp run -w lint:eslint:fix package.json pnpm-workspace.yaml web/docs
```
-Oxlint and Vite+ type-check scope is defined by `packages/tooling/lint.config.ts` `ignorePatterns`, and ESLint's scope is defined by `packages/tooling/eslint.ts` global ignores.
+Oxlint's scope is defined by `packages/tooling/lint.config.ts` `ignorePatterns`, and ESLint's scope is defined by `packages/tooling/eslint.ts` global ignores. Each package's `tsconfig.json` defines its type-check scope.
The primary rule baseline lives in `packages/tooling/lint.config.ts` and is connected through the root `vite.config.ts` `lint` block. Oxlint-native rules are preferred, and compatible ESLint rules can run through Oxlint's `jsPlugins` support. The rules are explicit snapshots of the ESLint configurations that were active at migration time. Do not import an upstream preset wholesale: enable a new rule intentionally and review its existing violations first.
@@ -106,7 +106,15 @@ The non-code baseline and its repository-wide file scope live in `packages/tooli
### Type-aware Linting
-The root configuration enables both `typeAware` and `typeCheck`, so `vp check` runs type-aware rules and full diagnostics through the repository's `@typescript/native` compiler.
+The root configuration enables `typeAware` and disables `typeCheck`, so `vp check` and `vp lint` run type-aware rules without reporting TypeScript compiler diagnostics. Run a package's `type-check` script separately for tsrs diagnostics, for example `vp run dify-web#type-check`.
+
+Run tsrs for the root tooling configuration and all workspace packages with:
+
+```sh
+vp run -r type-check
+```
+
+The TS Common CI job runs this command separately from formatting and linting.
The shared `packages/tsconfig/base.json` enforces erasable TypeScript syntax through
`erasableSyntaxOnly`. Root tooling and TypeScript packages inherit this contract; enum
diff --git a/packages/tooling/lint.config.ts b/packages/tooling/lint.config.ts
index dbfdbdb6a42..c4e48a228b1 100644
--- a/packages/tooling/lint.config.ts
+++ b/packages/tooling/lint.config.ts
@@ -593,7 +593,7 @@ export const lintConfig = {
reportUnusedDisableDirectives: 'error',
respectEslintDisableDirectives: false,
typeAware: true,
- typeCheck: true,
+ typeCheck: false,
},
settings: {
'better-tailwindcss': {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d6f15b5c0a6..a51de3b8ee2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -835,6 +835,9 @@ importers:
node:
specifier: runtime:24.22.1
version: runtime:24.22.1
+ tsrs:
+ specifier: 'catalog:'
+ version: 0.18.0-ts7.1.0-dev.20260929
typescript:
specifier: 'catalog:'
version: '@typescript/[email protected]'
diff --git a/tsconfig.json b/tsconfig.json
index eaf148e2600..5ef773f06b6 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,4 +1,7 @@
{
"extends": "./packages/tsconfig/node.json",
+ "compilerOptions": {
+ "allowImportingTsExtensions": true
+ },
"include": ["*.ts"]
}