diff --git a/package-lock.json b/package-lock.json index b6ce350..907cacc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "parse-server-kit", - "version": "3.0.4", + "version": "3.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "parse-server-kit", - "version": "3.0.4", + "version": "3.0.5", "license": "MIT", "bin": { "parse-server-kit": "dist/cli/index.js", diff --git a/package.json b/package.json index 87f0ba3..89ec2fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "parse-server-kit", - "version": "3.0.4", + "version": "3.0.5", "description": "Decorator-driven toolkit for Parse Server: models, cloud functions, triggers, cron, REST routing, ACL, transactions, optimistic locking and Swagger, from TypeScript decorators.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/templates/default/src/note.test.ts b/templates/default/src/note.test.ts index 1100d82..a9ee1e9 100644 --- a/templates/default/src/note.test.ts +++ b/templates/default/src/note.test.ts @@ -2,8 +2,24 @@ import {test, describe} from 'node:test'; import assert from 'node:assert/strict'; import './env'; -import Parse from 'parse/node'; -(global as unknown as {Parse: typeof Parse}).Parse = Parse; + +/* + * `require`, not `import`. + * + * The SDK has to be on the global before a model is imported, because + * `@ParseClass` registers the subclass while the module is being evaluated. + * + * A typed `import Parse from 'parse/node'` would do that too — but it also + * pulls in the type definitions the `parse` package ships, which disagree with + * `@types/parse` that the rest of the project uses. `getSessionToken()` is + * `string` in one and `string | null` in the other, and having both in a + * project produces errors that point at your code rather than at the clash. + * + * Requiring it sets the global without introducing a second source of types, + * so `Parse` here means the same thing it means everywhere else. + */ +// eslint-disable-next-line @typescript-eslint/no-var-requires +(global as unknown as {Parse: unknown}).Parse = require('parse/node'); import Note from './models/Note';