feat!: drop support for node 16 and 18 (#11382)

BREAKING CHANGE: TypeORM is now compiled for ECMAScript 2023, meaning old versions of Node.js are no longer supported. The minimum supported version of Node.js is 20.
This commit is contained in:
Lucian Mocanu 2025-09-30 18:51:33 +02:00 committed by GitHub
parent 925dee002b
commit 7fb6ba7ed9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 1544 additions and 111 deletions

View File

@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: "npm"
- run: npm ci
@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: "npm"
- run: npm ci
@ -54,7 +54,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
node-version: [20, 24]
uses: ./.github/workflows/tests-linux.yml
with:
node-version: ${{matrix.node-version}}
@ -63,7 +63,7 @@ jobs:
needs: build
uses: ./.github/workflows/tests-windows.yml
with:
node-version: 20
node-version: 22
# Run with most databases possible to provide the coverage of the tests
coverage:

View File

@ -23,7 +23,7 @@ jobs:
uses: actions/setup-node@v4
with:
cache: "npm"
node-version: 20
node-version: 22
- name: Install dependencies
run: npm ci

View File

@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm run package

View File

@ -9,7 +9,7 @@ on:
jobs:
cockroachdb:
# CockroachDB is slow, run less often so it doesn't block other workflows
if: ${{ inputs.node-version >= 20 }}
if: ${{ inputs.node-version >= 22 }}
runs-on: ubuntu-latest
services:

View File

@ -17,7 +17,7 @@
<br>
</div>
TypeORM 是一个 [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping) 框架,它可以运行在 NodeJS、Browser、Cordova、Ionic、React Native、Expo 和 Electron 平台上,可以与 TypeScript 和 JavaScript (ES2021)一起使用。 它的目标是始终支持最新的 JavaScript 特性并提供额外的特性以帮助你开发任何使用数据库的(不管是只有几张表的小型应用还是拥有多数据库的大型企业应用)应用程序。
TypeORM 是一个 [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping) 框架,它可以运行在 NodeJS、Browser、Cordova、Ionic、React Native、Expo 和 Electron 平台上,可以与 TypeScript 和 JavaScript (ES2023)一起使用。 它的目标是始终支持最新的 JavaScript 特性并提供额外的特性以帮助你开发任何使用数据库的(不管是只有几张表的小型应用还是拥有多数据库的大型企业应用)应用程序。
不同于现有的所有其他 JavaScript ORM 框架TypeORM 支持 [Active Record](./docs/docs/guides/1-active-record-data-mapper.md#what-is-the-active-record-pattern) 和 [Data Mapper](./docs/docs/guides/1-active-record-data-mapper.md#what-is-the-data-mapper-pattern) 模式,这意味着你可以以最高效的方式编写高质量的、松耦合的、可扩展的、可维护的应用程序。

View File

@ -17,13 +17,7 @@
<br>
</div>
TypeORM is an [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)
that can run in Node.js, Browser, Cordova, Ionic, React Native, NativeScript, Expo, and Electron platforms
and can be used with TypeScript and JavaScript (ES2021).
Its goal is to always support the latest JavaScript features and provide additional features
that help you to develop any kind of application that uses databases - from
small applications with a few tables to large-scale enterprise applications
with multiple databases.
TypeORM is an [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping) that can run in Node.js, Browser, Cordova, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES2023). Its goal is to always support the latest JavaScript features and provide additional features that help you to develop any kind of application that uses databases - from small applications with a few tables to large-scale enterprise applications with multiple databases.
TypeORM supports more databases than any other JS/TS ORM: [Google Spanner](./docs/docs/drivers/google-spanner.md), [Microsoft SqlServer](./docs/docs/drivers/microsoft-sqlserver.md), [MySQL/MariaDB](./docs/docs/drivers/mysql.md), [MongoDB](./docs/docs/drivers/mongodb.md), [Oracle](./docs/docs/drivers/oracle.md), [Postgres](./docs/docs/drivers/postgres.md), [SAP HANA](./docs/docs/drivers/sap.md) and [SQLite](./docs/docs/drivers/sqlite.md), as well we derived databases and different drivers.

View File

@ -17,7 +17,7 @@
<br>
</div>
TypeORM은 NodeJS, Browser, Cordova, Ionic, React Native, NativeScript, Expo 및 Electron 플랫폼에서 실행할 수 있는 [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)이며 TypeScript 및 JavaScript(ES2021)와 함께 사용할 수 있다. TypeORM의 목표는 항상 최신 JavaScript 기능을 지원하고 몇 개의 테이블이 있는 작은 응용 프로그램에서 여러 데이터베이스가 있는 대규모 엔터프라이즈 응용 프로그램에 이르기까지 데이터베이스를 사용하는 모든 종류의 응용 프로그램을 개발하는 데 도움이 되는 추가 기능을 제공하는 것이다.
TypeORM은 NodeJS, Browser, Cordova, Ionic, React Native, NativeScript, Expo 및 Electron 플랫폼에서 실행할 수 있는 [ORM](https://en.wikipedia.org/wiki/Object-relational_mapping)이며 TypeScript 및 JavaScript(ES2023)와 함께 사용할 수 있다. TypeORM의 목표는 항상 최신 JavaScript 기능을 지원하고 몇 개의 테이블이 있는 작은 응용 프로그램에서 여러 데이터베이스가 있는 대규모 엔터프라이즈 응용 프로그램에 이르기까지 데이터베이스를 사용하는 모든 종류의 응용 프로그램을 개발하는 데 도움이 되는 추가 기능을 제공하는 것이다.
TypeORM은 현재 존재하는 다른 모든 JavaScript ORM과 달리 [Active Record](./docs/docs/guides/1-active-record-data-mapper.md#what-is-the-active-record-pattern) 및 [Data Mapper](./docs/docs/guides/1-active-record-data-mapper.md#what-is-the-data-mapper-pattern) 패턴을 모두 지원한다. 즉, 고품질의 느슨하게 결합된 확장 가능하고 유지 관리 가능한 애플리케이션을 가장 생산적인 방식으로 작성할 수 있다.

View File

@ -64,8 +64,7 @@ export class Gulpfile {
@MergedTask()
browserCompile() {
const tsProject = ts.createProject("tsconfig.json", {
module: "es2020",
lib: ["es2021", "dom"],
lib: ["es2023", "dom"],
typescript: require("typescript")
});
const tsResult = gulp.src([

View File

@ -66,7 +66,7 @@
"logging": false
},
{
"skip": true,
"skip": false,
"name": "mssql",
"type": "mssql",
"host": "localhost",

1526
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{
"name": "typeorm",
"version": "0.3.27",
"description": "Data-Mapper ORM for TypeScript and ES2021+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.",
"description": "Data-Mapper ORM for TypeScript and ES2023+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.",
"homepage": "https://typeorm.io",
"bugs": {
"url": "https://github.com/typeorm/typeorm/issues"
@ -113,21 +113,22 @@
},
"devDependencies": {
"@eslint/js": "^9.36.0",
"@google-cloud/spanner": "^8.2.1",
"@sap/hana-client": "^2.26.18",
"@tsconfig/node16": "^16.1.5",
"@tsconfig/node20": "^20.1.6",
"@types/chai": "^4.3.20",
"@types/chai-as-promised": "^7.1.8",
"@types/debug": "^4.1.12",
"@types/gulp-rename": "^2.0.6",
"@types/gulp-sourcemaps": "^0.0.38",
"@types/mocha": "^10.0.10",
"@types/node": "^16.18.126",
"@types/node": "^20.19.18",
"@types/sha.js": "^2.4.4",
"@types/sinon": "^10.0.20",
"@types/sinon-chai": "^3.2.12",
"@types/source-map-support": "^0.5.10",
"@types/yargs": "^17.0.33",
"better-sqlite3": "^8.7.0",
"better-sqlite3": "^12.4.1",
"chai": "^4.5.0",
"chai-as-promised": "^7.1.2",
"class-transformer": "^0.5.1",
@ -148,7 +149,7 @@
"mongodb": "^6.20.0",
"mssql": "^11.0.1",
"mysql": "^2.18.1",
"mysql2": "^3.15.0",
"mysql2": "^3.15.1",
"nyc": "^17.1.0",
"oracledb": "^6.9.0",
"pg": "^8.16.3",
@ -170,22 +171,22 @@
"typescript-eslint": "^8.44.0"
},
"peerDependencies": {
"@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0",
"@google-cloud/spanner": "^8.0.0",
"@sap/hana-client": "^2.14.22",
"better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0",
"better-sqlite3": "^12.0.0",
"ioredis": "^5.0.4",
"mongodb": "^5.8.0 || ^6.0.0",
"mssql": "^9.1.1 || ^10.0.1 || ^11.0.1",
"mysql2": "^2.2.5 || ^3.0.1",
"mongodb": "^6.0.0",
"mssql": "^11.0.1",
"mysql2": "^3.0.1",
"oracledb": "^6.3.0",
"pg": "^8.5.1",
"pg-native": "^3.0.0",
"pg-query-stream": "^4.0.0",
"redis": "^3.1.1 || ^4.0.0 || ^5.0.14",
"redis": "^5.0.14",
"sql.js": "^1.4.0",
"sqlite3": "^5.0.3",
"ts-node": "^10.7.0",
"typeorm-aurora-data-api-driver": "^2.0.0 || ^3.0.0"
"ts-node": "^10.9.2",
"typeorm-aurora-data-api-driver": "^3.0.0"
},
"peerDependenciesMeta": {
"@google-cloud/spanner": {
@ -238,7 +239,7 @@
}
},
"engines": {
"node": ">=16.13.0"
"node": "^20.9.0 || >=22.11.0"
},
"collective": {
"type": "opencollective",

View File

@ -262,8 +262,8 @@ export const AppDataSource = new DataSource({
return JSON.stringify(
{
compilerOptions: {
lib: ["es2021"],
target: "es2021",
lib: ["es2023"],
target: "es2022",
module: "es2022",
moduleResolution: "node",
allowSyntheticDefaultImports: true,
@ -280,8 +280,8 @@ export const AppDataSource = new DataSource({
return JSON.stringify(
{
compilerOptions: {
lib: ["es2021"],
target: "es2021",
lib: ["es2023"],
target: "es2022",
module: "commonjs",
moduleResolution: "node",
outDir: "./build",
@ -699,29 +699,29 @@ Steps to run this project:
switch (database) {
case "mysql":
case "mariadb":
packageJson.dependencies["mysql2"] = "^3.14.0"
packageJson.dependencies["mysql2"] = "^3.15.1"
break
case "postgres":
case "cockroachdb":
packageJson.dependencies["pg"] = "^8.14.1"
packageJson.dependencies["pg"] = "^8.16.3"
break
case "sqlite":
packageJson.dependencies["sqlite3"] = "^5.1.7"
break
case "better-sqlite3":
packageJson.dependencies["better-sqlite3"] = "^8.7.0"
packageJson.dependencies["better-sqlite3"] = "^12.4.1"
break
case "oracle":
packageJson.dependencies["oracledb"] = "^6.8.0"
packageJson.dependencies["oracledb"] = "^6.9.0"
break
case "mssql":
packageJson.dependencies["mssql"] = "^10.0.4"
packageJson.dependencies["mssql"] = "^11.0.1"
break
case "mongodb":
packageJson.dependencies["mongodb"] = "^6.15.0"
packageJson.dependencies["mongodb"] = "^6.20.0"
break
case "spanner":
packageJson.dependencies["@google-cloud/spanner"] = "^7.19.1 "
packageJson.dependencies["@google-cloud/spanner"] = "^8.2.1 "
break
}

View File

@ -10,7 +10,7 @@ import { ApplyValueTransformers } from "../../util/ApplyValueTransformers"
import { DriverUtils } from "../DriverUtils"
abstract class PostgresWrapper extends PostgresDriver {
options: any
declare options: any
abstract createQueryRunner(mode: ReplicationMode): any
}

View File

@ -10,7 +10,7 @@ import { Table } from "../../schema-builder/table/Table"
import { TypeORMError } from "../../error"
class PostgresQueryRunnerWrapper extends PostgresQueryRunner {
driver: any
declare driver: any
constructor(driver: any, mode: ReplicationMode) {
super(driver, mode)
@ -31,19 +31,10 @@ export class AuroraPostgresQueryRunner
/**
* Database driver used by connection.
*/
driver: AuroraPostgresDriver
declare driver: AuroraPostgresDriver
protected client: any
// -------------------------------------------------------------------------
// Protected Properties
// -------------------------------------------------------------------------
/**
* Promise used to obtain a database connection for a first time.
*/
protected databaseConnectionPromise: Promise<any>
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------

View File

@ -24,11 +24,6 @@ export class BetterSqlite3Driver extends AbstractSqliteDriver {
*/
options: BetterSqlite3ConnectionOptions
/**
* SQLite underlying library.
*/
sqlite: any
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------

View File

@ -8,7 +8,7 @@ import { ReplicationMode } from "../types/ReplicationMode"
export class CapacitorDriver extends AbstractSqliteDriver {
driver: any
options: CapacitorConnectionOptions
declare options: CapacitorConnectionOptions
// -------------------------------------------------------------------------
// Constructor

View File

@ -14,7 +14,7 @@ interface Window {
declare let window: Window
export class CordovaDriver extends AbstractSqliteDriver {
options: CordovaConnectionOptions
declare options: CordovaConnectionOptions
transactionSupport = "none" as const

View File

@ -5,7 +5,7 @@ import { QueryRunner } from "../../query-runner/QueryRunner"
import { DataSource } from "../../data-source/DataSource"
export class ExpoDriver extends AbstractSqliteDriver {
options: ExpoConnectionOptions
declare options: ExpoConnectionOptions
constructor(connection: DataSource) {
super(connection)

View File

@ -6,7 +6,7 @@ import { DataSource } from "../../../data-source/DataSource"
import { ReplicationMode } from "../../types/ReplicationMode"
export class ExpoLegacyDriver extends AbstractSqliteDriver {
options: ExpoConnectionOptions
declare options: ExpoConnectionOptions
// -------------------------------------------------------------------------
// Constructor

View File

@ -24,11 +24,6 @@ export class SqliteDriver extends AbstractSqliteDriver {
*/
options: SqliteConnectionOptions
/**
* SQLite underlying library.
*/
sqlite: any
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------

View File

@ -21,7 +21,7 @@ declare let window: Window
export class SqljsDriver extends AbstractSqliteDriver {
// The driver specific options.
options: SqljsConnectionOptions
declare options: SqljsConnectionOptions
// -------------------------------------------------------------------------
// Constructor

View File

@ -60,7 +60,7 @@ export class MongoRepository<
/**
* Entity Manager used by this repository.
*/
readonly manager: MongoEntityManager
declare readonly manager: MongoEntityManager
// -------------------------------------------------------------------------
// Overridden Methods

View File

@ -46,13 +46,15 @@ describe("query runner > stream", () => {
const readStream = await queryRunner.stream(query)
if (!(connection.driver.options.type === "spanner"))
await new Promise((ok) => readStream.once("readable", ok))
await new Promise<void>((ok) =>
readStream.once("readable", ok),
)
const data: any[] = []
readStream.on("data", (row) => data.push(row))
await new Promise((ok, fail) => {
await new Promise<void>((ok, fail) => {
readStream.once("end", ok)
readStream.once("error", fail)
})

View File

@ -2,7 +2,6 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
@ -18,9 +17,10 @@
"strictFunctionTypes": false,
"strictPropertyInitialization": false,
"stripInternal": true,
"useDefineForClassFields": false,
"useUnknownInCatchVariables": false
},
"exclude": ["build", "node_modules", "temp", "tmp", "sample/playground"],
"extends": "@tsconfig/node16/tsconfig.json",
"extends": "@tsconfig/node20/tsconfig.json",
"include": ["sample", "src", "test", "*.ts"]
}