diff --git a/package.json b/package.json index 5601e5c..af89f6f 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,9 @@ "lint": "rslint", "lint:write": "rslint --fix", "prettier:ci": "prettier --check .", - "test": "pnpm run test:install && pnpm run build && rstest", - "test:install": "cross-env ./node_modules/.bin/puppeteer browsers install chrome" + "test": "pnpm run test:install && pnpm run test:type && rstest", + "test:install": "cross-env ./node_modules/.bin/puppeteer browsers install chrome", + "test:type": "pnpm run build && pnpm --dir tests run type-check" }, "simple-git-hooks": { "pre-commit": "npx nano-staged" diff --git a/tests/package.json b/tests/package.json index 932b8c0..b9eca24 100644 --- a/tests/package.json +++ b/tests/package.json @@ -2,6 +2,9 @@ "name": "tests", "private": true, "type": "commonjs", + "scripts": { + "type-check": "pnpm exec tsc -p type-tests/resolution-bundler/tsconfig.json && pnpm exec tsc -p type-tests/resolution-nodenext/tsconfig.json" + }, "devDependencies": { "@module-federation/runtime-tools": "^2.1.0", "@rspack/dev-server": "workspace:*" diff --git a/tests/type-tests/resolution-bundler/index.ts b/tests/type-tests/resolution-bundler/index.ts new file mode 100644 index 0000000..5f0ce50 --- /dev/null +++ b/tests/type-tests/resolution-bundler/index.ts @@ -0,0 +1,9 @@ +// This folder disables `skipLibCheck` to check the public types of @rspack/dev-server. +import '@rspack/dev-server/client/index'; +import { RspackDevServer } from '@rspack/dev-server'; +import type { Configuration } from '@rspack/dev-server'; + +const config: Configuration = {}; + +void config; +void RspackDevServer; diff --git a/tests/type-tests/resolution-bundler/tsconfig.json b/tests/type-tests/resolution-bundler/tsconfig.json new file mode 100644 index 0000000..6aa69d7 --- /dev/null +++ b/tests/type-tests/resolution-bundler/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "module": "ES2022", + "moduleResolution": "bundler", + "target": "ES2023", + "strict": true, + "skipLibCheck": false, + "noEmit": true + }, + "include": ["index.ts"] +} diff --git a/tests/type-tests/resolution-nodenext/index.ts b/tests/type-tests/resolution-nodenext/index.ts new file mode 100644 index 0000000..ca9a026 --- /dev/null +++ b/tests/type-tests/resolution-nodenext/index.ts @@ -0,0 +1,9 @@ +// This folder disables `skipLibCheck` to check the public types of @rspack/dev-server. +import '@rspack/dev-server/client/index.js'; +import { RspackDevServer } from '@rspack/dev-server'; +import type { Configuration } from '@rspack/dev-server'; + +const config: Configuration = {}; + +void config; +void RspackDevServer; diff --git a/tests/type-tests/resolution-nodenext/tsconfig.json b/tests/type-tests/resolution-nodenext/tsconfig.json new file mode 100644 index 0000000..cf3de37 --- /dev/null +++ b/tests/type-tests/resolution-nodenext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "target": "ES2023", + "strict": true, + "skipLibCheck": false, + "noEmit": true + }, + "include": ["index.ts"] +}