fix: web build typescript errors
- Drop tsconfig.node.json: composite + noEmit conflict, and the vite.config.ts doesn't need its own project / node types. - Inline vite.config.ts in the main tsconfig include list. - Switch web build from `tsc -b` to `tsc --noEmit` since there are no project references anymore. - Make b64urlDecode return Uint8Array<ArrayBuffer> so its output is accepted by crypto.subtle.verify under stricter lib types. - Cast the Pages EventContext to ExecutionContext when forwarding to Hono; props is unused at runtime. https://claude.ai/code/session_01TPBqgcSJMppgrpiq7fLywL
This commit is contained in:
parent
a1ebc0725b
commit
89b1221706
@ -77,11 +77,12 @@ async function verifyAccessJwt(
|
|||||||
return valid ? payload : null;
|
return valid ? payload : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function b64urlDecode(s: string): Uint8Array {
|
function b64urlDecode(s: string): Uint8Array<ArrayBuffer> {
|
||||||
const pad = s.length % 4 === 0 ? '' : '='.repeat(4 - (s.length % 4));
|
const pad = s.length % 4 === 0 ? '' : '='.repeat(4 - (s.length % 4));
|
||||||
const b64 = (s + pad).replace(/-/g, '+').replace(/_/g, '/');
|
const b64 = (s + pad).replace(/-/g, '+').replace(/_/g, '/');
|
||||||
const bin = atob(b64);
|
const bin = atob(b64);
|
||||||
const out = new Uint8Array(bin.length);
|
const buf = new ArrayBuffer(bin.length);
|
||||||
|
const out = new Uint8Array(buf);
|
||||||
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,4 +4,4 @@ import type { AppEnv } from '@leetete/api/env';
|
|||||||
const app = createApp();
|
const app = createApp();
|
||||||
|
|
||||||
export const onRequest: PagesFunction<AppEnv> = (ctx) =>
|
export const onRequest: PagesFunction<AppEnv> = (ctx) =>
|
||||||
app.fetch(ctx.request, ctx.env, ctx);
|
app.fetch(ctx.request, ctx.env, ctx as unknown as ExecutionContext);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc --noEmit && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"deploy": "wrangler pages deploy dist --project-name stefanieeleandro",
|
"deploy": "wrangler pages deploy dist --project-name stefanieeleandro",
|
||||||
|
|||||||
@ -6,6 +6,5 @@
|
|||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"types": ["vite/client", "@cloudflare/workers-types"]
|
"types": ["vite/client", "@cloudflare/workers-types"]
|
||||||
},
|
},
|
||||||
"include": ["src/**/*", "functions/**/*"],
|
"include": ["src/**/*", "functions/**/*", "vite.config.ts"]
|
||||||
"references": [{ "path": "./tsconfig.node.json" }]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../../tsconfig.base.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"composite": true,
|
|
||||||
"noEmit": true,
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "Bundler",
|
|
||||||
"types": ["node"]
|
|
||||||
},
|
|
||||||
"include": ["vite.config.ts"]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user