From 669dc87d5ffb4530ef5e09ca1dabeced8303ba95 Mon Sep 17 00:00:00 2001 From: Eric Hwang Date: Mon, 22 Jul 2024 14:25:40 -0700 Subject: [PATCH 1/3] [TS typings] Fix typing for util.use(plugin, options) to allow strongly typed plugin functions Resolves error introduced in racer@2.2.0 where Derby app.use plugins had TS compile errors --- src/util.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util.ts b/src/util.ts index 9774563f..4d1a276f 100644 --- a/src/util.ts +++ b/src/util.ts @@ -229,6 +229,8 @@ export function serverUse(module, id: string, options?: unknown) { return this.use(plugin, options); } +type Plugin = (pluginHost: T, options: O) => void; + /** * Use plugin * @@ -236,9 +238,9 @@ export function serverUse(module, id: string, options?: unknown) { * @param options - Optional options passed to plugin * @returns */ -export function use(plugin: (arg0: unknown, options?: unknown) => void, options?: unknown) { +export function use(this: T, plugin: Plugin, options?: O) { // Don't include a plugin more than once - var plugins = this._plugins || (this._plugins = []); + var plugins = (this as any)._plugins || ((this as any)._plugins = []); if (plugins.indexOf(plugin) === -1) { plugins.push(plugin); plugin(this, options); From cd397f6cee132e23da46e1e84c23e88724fbc7ce Mon Sep 17 00:00:00 2001 From: Eric Hwang Date: Mon, 22 Jul 2024 14:29:42 -0700 Subject: [PATCH 2/3] Fix errors with TS 5.5, switch typescript to '~' dependency specifier since TypeScript doesn't use semver - Remove noImplicitUseStrict compiler flag, since TS 5.5 no longer supports it - Put preserve="true" on triple-slash reference directives used to load types for server-only model methods, since TS 5.5 strips the directives without the new preserve attribute --- package.json | 2 +- src/Model/index.ts | 4 ++-- tsconfig.json | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 191547d7..68bb3cde 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "typedoc": "^0.25.13", "typedoc-plugin-mdn-links": "^3.1.28", "typedoc-plugin-missing-exports": "^2.2.0", - "typescript": "^5.1.3" + "typescript": "~5.5" }, "bugs": { "url": "https://github.com/derbyjs/racer/issues" diff --git a/src/Model/index.ts b/src/Model/index.ts index 435e907c..9c7e143c 100644 --- a/src/Model/index.ts +++ b/src/Model/index.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import { serverRequire } from '../util'; export { Model, ChildModel, RootModel, type ModelOptions, type UUID, type DefualtType } from './Model'; diff --git a/tsconfig.json b/tsconfig.json index f75922da..2fa026cd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,8 @@ { "compilerOptions": { "allowJs": true, - "ignoreDeprecations": "5.0", "lib":[], "module": "CommonJS", - "noImplicitUseStrict": true, "outDir": "lib", "target": "ES5", "sourceMap": false, From db2917cc20b23e3e39bfbc37a29dabf870e4c056 Mon Sep 17 00:00:00 2001 From: Eric Hwang Date: Mon, 22 Jul 2024 14:42:38 -0700 Subject: [PATCH 3/3] [docs] Update to typedoc 0.26, for TS 5.5 compatibility --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 68bb3cde..8bd9eea2 100644 --- a/package.json +++ b/package.json @@ -42,9 +42,9 @@ "eslint-config-google": "^0.14.0", "mocha": "^9.1.3", "nyc": "^15.1.0", - "typedoc": "^0.25.13", + "typedoc": "^0.26.5", "typedoc-plugin-mdn-links": "^3.1.28", - "typedoc-plugin-missing-exports": "^2.2.0", + "typedoc-plugin-missing-exports": "^3.0.0", "typescript": "~5.5" }, "bugs": {