Emit .d.ts types for NPM package
Some checks are pending
Publish to npm / test (push) Waiting to run
Publish to npm / get-version (push) Waiting to run
Publish to npm / npm-publish (push) Blocked by required conditions
Node.js CI / build (18.x) (push) Waiting to run

This commit is contained in:
Guangcong Luo 2025-02-26 02:43:54 -08:00
parent 72bd8baf9e
commit 62023bd299
5 changed files with 10 additions and 5 deletions

View File

@ -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;

View File

@ -163,7 +163,7 @@ export class QueryProcessWrapper<T, U> 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;
}
}

View File

@ -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;

View File

@ -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",

View File

@ -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": [