diff --git a/lib/crashlogger.ts b/lib/crashlogger.ts index 092c1eeb076c9..d6e3ac5ef5abc 100644 --- a/lib/crashlogger.ts +++ b/lib/crashlogger.ts @@ -16,7 +16,7 @@ const CRASH_EMAIL_THROTTLE = 5 * 60 * 1000; // 5 minutes const logPath = path.resolve( // not sure why this is necessary, but in Windows testing it was __dirname, '../', __dirname.includes(`${path.sep}dist${path.sep}`) ? '..' : '', - path.join(global.Config?.logsdir || 'logs', 'errors.txt') + path.join((global as any).Config?.logsdir || 'logs', 'errors.txt') ); let lastCrashLog = 0; let transport: any; @@ -50,7 +50,7 @@ export function crashlogger( console.error(`\nSUBCRASH: ${err.stack}\n`); }); - const emailOpts = emailConfig || global.Config?.crashguardemail; + const emailOpts = emailConfig || (global as any).Config?.crashguardemail; if (emailOpts && ((datenow - lastCrashLog) > CRASH_EMAIL_THROTTLE)) { lastCrashLog = datenow; diff --git a/lib/process-manager.ts b/lib/process-manager.ts index 96248ee6399ef..792a2df030426 100644 --- a/lib/process-manager.ts +++ b/lib/process-manager.ts @@ -163,7 +163,7 @@ export class QueryProcessWrapper implements ProcessWrapper { // it's also futureproofing in case other external modfules require this // we also specifically do not throw here because this json might be sensitive, // so we only want it to go to emails - global.Monitor?.crashlog?.(e, `a ${path.basename(this.file)} process`, { result: obj }); + (global as any).Monitor?.crashlog?.(e, `a ${path.basename(this.file)} process`, { result: obj }); return undefined; } } diff --git a/lib/sql.ts b/lib/sql.ts index ac308c9b8052f..6d47321079780 100644 --- a/lib/sql.ts +++ b/lib/sql.ts @@ -62,6 +62,8 @@ type ErrorHandler = (error: Error, data: DatabaseQuery, isParentProcess: boolean function getModule() { try { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore does not exist while building NPM package??? return require('better-sqlite3') as typeof sqlite.default; } catch { return null; diff --git a/package.json b/package.json index 960f6e05b69b6..afed775fd428b 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "description": "The server for the Pokémon Showdown battle simulator", "version": "0.11.9", "main": "dist/sim/index.js", + "types": "dist/sim/index.d.ts", "dependencies": { "esbuild": "^0.16.10", "mysql2": "^3.9.7", @@ -34,6 +35,8 @@ "scripts": { "start": "node pokemon-showdown start", "build": "node build", + "build-npm": "npx tsc sim/global-types.ts sim/index.ts --declaration --emitDeclarationOnly --declarationDir dist/ --target es2020 --strict --moduleResolution node --types node --lib es2020", + "test-npm": "npx tsc sim/global-types.ts sim/index.ts --noEmit --target es2020 --strict --moduleResolution node --types node --lib es2020", "tsc": "tsc", "lint": "eslint --cache", "fix": "eslint --cache --fix", @@ -42,7 +45,7 @@ "test": "mocha", "posttest": "npm run tsc", "full-test": "npm run lint && npm run tsc && mocha --timeout 8000 --forbid-only -g \".*\"", - "full-test-ci": "eslint --max-warnings 0 && tsc && (([ \"$SKIPSIMTESTS\" = true ] && mocha --timeout 8000 --forbid-only -g \".*\" --exclude \"test/{sim,random-battles}/**\") || mocha --timeout 8000 --forbid-only -g \".*\")", + "full-test-ci": "eslint --max-warnings 0 && tsc && (([ \"$SKIPSIMTESTS\" = true ] && mocha --timeout 8000 --forbid-only -g \".*\" --exclude \"test/{sim,random-battles}/**\") || mocha --timeout 8000 --forbid-only -g \".*\") && npm run test-npm", "postinstall": "npm run build postinstall" }, "bin": "./pokemon-showdown", diff --git a/tsconfig.json b/tsconfig.json index 0da0a4cfc69f8..ea1a8a364b241 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,7 @@ "types": ["node"], "exclude": [ "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts", - "./.*-dist/**/*", + "./dist/**/*", "./server/chat-plugins/private/*/*.d.ts" ], "include": [