chore(scripts): add proper typechecking

This commit is contained in:
Elian Doran 2025-12-08 13:09:22 +02:00
parent 3ee8eac635
commit baee2cd6b2
No known key found for this signature in database
5 changed files with 24 additions and 3 deletions

View File

@ -65,7 +65,7 @@ async function getFirstPageResults(context: BrowserContext) {
for (const link of allDiscussionLinks) {
const url = await link.getAttribute('href');
const number = url?.match(/\/discussions\/(\d+)/)?.[1];
ids.push(number);
if (number) ids.push(number);
}
console.log(`Found ${ids.length} discussions.`);
await page.close();

View File

@ -34,5 +34,5 @@ function replaceTranslation(path: string, value: string) {
cursor = cursor[current];
}
cursor[lastSegment] = value;
if (lastSegment) cursor[lastSegment] = value;
}

View File

@ -18,7 +18,7 @@ async function getLanguageStats() {
return JSON.parse(await readFile(cacheFile, "utf-8"));
}
} catch (e) {
if (e.code !== "ENOENT") {
if (!(e && typeof e === "object" && "code" in e && e.code === "ENOENT")) {
throw e;
}
}

18
scripts/tsconfig.json Normal file
View File

@ -0,0 +1,18 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler",
"target": "es2023",
"outDir": "dist",
"types": [
"node",
"express"
],
"tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo"
},
"include": [
"**/*.ts"
],
"references": []
}

View File

@ -62,6 +62,9 @@
},
{
"path": "./packages/share-theme"
},
{
"path": "./scripts"
}
]
}