Skip to content

Commit c653214

Browse files
committed
chore: enforce min TS version (#1194)
1 parent 59a89d4 commit c653214

9 files changed

+4107
-6
lines changed

.github/workflows/test.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,17 @@ jobs:
208208
- name: Run build with newer TypeScript
209209
run: npm run build
210210

211-
- name: Install older TypeScript
212-
run: npm i -D typescript@${{ matrix.typescript-version }} tsd@${{ fromJson('{ "^4.6":"0.20.0", "^4.7":"0.22.0", "^4.8":"0.24.1", "^4.9":"0.27.0", "^5.0":"0.28.1", "^5.2":"0.29.0", "^5.3":"0.30.7", "^5.4":"0.31.2" }')[matrix.typescript-version] }}
211+
- run: |
212+
echo "TS_VERSION=${{ matrix.typescript-version }}" >> $GITHUB_ENV
213+
echo "TSD_VERSION=${{ fromJson('{ "^4.6":"0.20.0", "^4.7":"0.22.0", "^4.8":"0.24.1", "^4.9":"0.27.0", "^5.0":"0.28.1", "^5.2":"0.29.0", "^5.3":"0.30.7", "^5.4":"0.31.2" }')[env.TS_VERSION] }} >> $GITHUB_ENV"
214+
215+
- name: Install Typescript (${{ env.TS_VERSION }}) and TSD (${{ env.TSD_VERSION }})
216+
run: npm i -D typescript@${{ env.TS_VERSION }} tsd@${{ env.TSD_VERSION }}
213217

214218
- name: Exclude non-backward compatible tests
215219
run: npx tsx ./scripts/exclude-test-files-for-backwards-compat.mts
216220

217-
- name: Run tests with older TypeScript
221+
- name: Run tests with older TypeScript version
218222
run: npm run test:typings && npm run test:node:build
219223

220224
jsdocs:

.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ package-lock.json
1616
tsconfig-base.json
1717
tsconfig-cjs.json
1818
tsconfig.json
19-
19+
CONTRIBUTING.md

outdated-typescript.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { KyselyTypeError } from './dist/cjs/util/type-error'
2+
3+
declare const Kysely: KyselyTypeError<'The installed TypeScript version is outdated and cannot guarantee type-safety with Kysely. Please upgrade to version 4.6 or newer.'>
4+
declare const RawBuilder: KyselyTypeError<'The installed TypeScript version is outdated and cannot guarantee type-safety with Kysely. Please upgrade to version 4.6 or newer.'>
5+
declare const sql: KyselyTypeError<'The installed TypeScript version is outdated and cannot guarantee type-safety with Kysely. Please upgrade to version 4.6 or newer.'>

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@
77
"url": "git://github.com/kysely-org/kysely.git"
88
},
99
"engines": {
10-
"node": ">=14.0.0"
10+
"node": ">=18.0.0"
1111
},
1212
"main": "dist/cjs/index.js",
1313
"module": "dist/esm/index.js",
14+
"typesVersions": {
15+
"<4.6": {
16+
"*": [
17+
"outdated-typescript.d.ts"
18+
]
19+
}
20+
},
1421
"exports": {
1522
".": {
1623
"import": "./dist/esm/index.js",
@@ -54,6 +61,7 @@
5461
"test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null",
5562
"test:exports": "attw --pack . && node scripts/check-exports.js",
5663
"test:jsdocs": "deno check --doc-only --no-lock --unstable-sloppy-imports --config=\"deno.check.json\" ./src",
64+
"test:outdatedts": "npm run build && cd test/outdated-ts && npm ci && npm test",
5765
"prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
5866
"build": "npm run clean && (npm run build:esm & npm run build:cjs) && npm run script:module-fixup && npm run script:copy-interface-doc",
5967
"build:esm": "tsc -p tsconfig.json && npm run script:add-deno-type-references",

test/outdated-ts/outdated-ts.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Kysely, RawBuilder, sql } from 'kysely'
2+
import { KyselyTypeError } from '../../src/util/type-error'
3+
4+
function expectOutdatedTSError(
5+
_: KyselyTypeError<'The installed TypeScript version is outdated and cannot guarantee type-safety with Kysely. Please upgrade to version 4.6 or newer.'>,
6+
): void {}
7+
8+
expectOutdatedTSError(Kysely)
9+
expectOutdatedTSError(RawBuilder)
10+
expectOutdatedTSError(sql)

0 commit comments

Comments
 (0)