From 4cde2c88aad90eb3e3e12de61b748a24f72c42df Mon Sep 17 00:00:00 2001 From: stjet <49297268+stjet@users.noreply.github.com> Date: Sun, 12 Apr 2026 07:02:36 +0000 Subject: [PATCH] satisfy typescript for github actions --- preview.ts | 9 +++++---- ryuji.ts | 12 +++++++----- tsconfig.json | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/preview.ts b/preview.ts index 2932569..f515255 100644 --- a/preview.ts +++ b/preview.ts @@ -6,13 +6,14 @@ const port: number = 8042; createServer((req, res) => { let req_path: string; - if (!req.url.includes(".")) { - req_path = path.join(__dirname, "build", req.url, "index.html"); + let req_url = req.url ?? ""; //fucking typescript shit. there will be a url trust me + if (!req_url.includes(".")) { + req_path = path.join(__dirname, "build", req_url, "index.html"); } else { - req_path = path.join(__dirname, "build", req.url); + req_path = path.join(__dirname, "build", req_url); } let status_code = 200; - //req.url.includes("..") + //req_url.includes("..") if (!req_path.startsWith(path.join(__dirname, "build"))) { //nice try, bad request res.writeHead(400); diff --git a/ryuji.ts b/ryuji.ts index 6ecd3d5..b5c9d4a 100644 --- a/ryuji.ts +++ b/ryuji.ts @@ -39,7 +39,8 @@ export class Renderer { return `${path1.slice(0, path1.length-1)}${path2}`; } else if ((!path1.endsWith("/") && path2.startsWith("/")) || (path1.endsWith("/") && !path2.startsWith("/"))) { return `${path1}${path2}`; - } else if (!path1.endsWith("/") && !path2.startsWith("/")) { + } else { + //} else if (!path1.endsWith("/") && !path2.startsWith("/")) { return `${path1}/${path2}`; } } @@ -133,7 +134,7 @@ export class Renderer { if (var_value.length === 0) { //skip straight to the endfor let sliced = matches.slice(index+1, matches.length); - let new_index: number; + let new_index: number | undefined; let extra_fors: number = 0; for (let i=0; i < sliced.length; i++) { if (sliced[i][0].startsWith("[[ for:")) { @@ -198,7 +199,7 @@ export class Renderer { } let var_value2 = Renderer.get_var(var_name2, vars); if (if_in) { - var_value2 = var_value2.find((ele) => ele === var_value); + var_value2 = var_value2.find((ele: any) => ele === var_value); } if (if_not) { //make sure the two compared variables are NOT equal @@ -232,6 +233,7 @@ export class Renderer { extra_ifs--; } } + // @ts-ignore if (typeof new_index === "undefined") throw Error("`if:` statement missing an `[[ endif ]]`"); index += new_index+1; continue; @@ -257,8 +259,8 @@ export class Renderer { if (current_last[i] !== " ") break; indentation++; } - let var_lines: string[] = var_value.split("\n"); - let var_first: string = var_lines.shift(); + let var_lines: string[] = var_value.split("\n") as string[]; //dunno why typescript thinks it could be undefined + let var_first: string = var_lines.shift() as string; //we know var_lines has at least one element //append spaces var_value = var_lines.length === 0 ? var_first : var_first+"\n"+var_lines.map((var_line) => " ".repeat(indentation)+var_line).join("\n"); if (exp_parts[0] === "html") { diff --git a/tsconfig.json b/tsconfig.json index 57f2d8d..2696370 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "target": "esnext", + "strict": true, "module": "nodenext", "moduleResolution": "nodenext", "types": ["node"],