Skip to content

Commit 510f94c

Browse files
authored
ci: type-check in CI instead of leaning on the test runner (#4)
Type checking only happened as a side effect of ts-node compiling test files on the way in, and it surfaced as an unrelated-looking module resolution error rather than a type error. CI never called the check-types script that already existed. Running the tests transpile-only and type checking as its own step splits the two concerns, but tsconfig.json excludes the test tree so that tsup emits declarations for src alone. Checking that config by itself would have left test files unchecked by anything, so a second config covers them, and check-types runs both.
1 parent 80580c5 commit 510f94c

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ jobs:
2424
- name: Install
2525
run: yarn install --frozen-lockfile
2626

27+
# Type-checks src and the test tree. tsconfig.json excludes the test
28+
# tree so that tsup emits declarations for src alone, so this needs the
29+
# dedicated tsconfig.test.json to cover what that one doesn't.
30+
- name: Type check
31+
run: yarn run check-types
32+
2733
- name: Build
2834
run: yarn run build
2935

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
],
4848
"scripts": {
4949
"build": "tsup",
50-
"check-types": "tsc --noEmit",
50+
"check-types": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
5151
"lint": "eslint .",
5252
"pretest": "tsup",
53-
"test": "mocha -r ts-node/register test/**/*.test.ts",
53+
"test": "mocha -r ts-node/register/transpile-only test/**/*.test.ts",
5454
"prepare": "tsup",
5555
"prepack": "tsup"
5656
},

‎tsconfig.test.json‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Type-checks the test tree, plus whatever src files the tests import.
2+
// tsconfig.json excludes the test tree so that tsup builds and emits
3+
// declarations for src alone; rootDir widens to the repo root because the
4+
// test files sit outside src.
5+
{
6+
"extends": "./tsconfig.json",
7+
"compilerOptions": {
8+
"rootDir": ".",
9+
"declaration": false,
10+
"noEmit": true
11+
},
12+
"include": ["test/**/*.ts"],
13+
"exclude": ["node_modules"]
14+
}

0 commit comments

Comments
 (0)