Skip to content

Commit 952df86

Browse files
sametbasbugclaude
andcommitted
Make the typecheck run, and keep it running
tsconfig set `baseUrl: "."`, which TypeScript 6 rejects outright, so `tsc --noEmit` died before reading a single file -- the typecheck had been off for as long as the option has been deprecated, and nobody saw an error because there was no output to see. `paths` has not needed `baseUrl` since TypeScript 5; the entries are now tsconfig-relative. With tsc actually running, 14 errors appeared. Twelve were one cause: the Worker surface had no Cloudflare types at all, so `D1Database`, `R2Bucket`, `ExportedHandler` and `cloudflare:workers` were unresolved. `wrangler types` generates them; the output is committed because the typecheck cannot run without it. Regenerating twice produces an identical file, so CI can diff it -- a stale copy now fails the build instead of quietly weakening the check. The other two: base64UrlToBytes was declared as bare `Uint8Array`, which widens to `ArrayBufferLike` and so admits SharedArrayBuffer, while crypto.subtle.verify wants an ArrayBuffer-backed view. The runtime value was always ArrayBuffer-backed; only the declaration was loose. And the astro:config:setup hook parameter got a JSDoc type. `npm run typecheck` now exists, quality.yml runs it, and `npm run quality` covers tests + typecheck + build. Without the CI step this would have rotted back to zero the same silent way. 212 tests pass, 0 type errors, both builds complete. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent bce0ef7 commit 952df86

6 files changed

Lines changed: 15120 additions & 5 deletions

File tree

‎.github/workflows/quality.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ jobs:
4444
- name: Install Node dependencies
4545
run: npm ci
4646

47+
# `worker-configuration.d.ts` üretilmiş bir dosya ama depoda duruyor:
48+
# tür kontrolü onsuz `D1Database`, `R2Bucket` ve `ExportedHandler`ı
49+
# bulamıyor. Depodaki kopya `wrangler.ssr.jsonc` değiştiğinde sessizce
50+
# bayatlayabilir; bu adım yeniden üretip fark varsa düşüyor.
51+
- name: Check the generated Worker types are current
52+
run: |
53+
cp worker-configuration.d.ts /tmp/worker-types-committed.d.ts
54+
npm run types:gen
55+
diff --unified /tmp/worker-types-committed.d.ts worker-configuration.d.ts \
56+
|| { echo 'worker-configuration.d.ts bayat: `npm run types:gen` çalıştırıp commit edin.' >&2; exit 1; }
57+
58+
# Tür kontrolü 2026-08-21'e kadar HİÇ koşmuyordu: tsconfig'deki
59+
# deprecated `baseUrl` TS 6'da hata verip tsc'yi daha başlamadan
60+
# düşürüyordu. Kaldırıldığında 14 gerçek hata çıktı.
61+
- name: Typecheck
62+
run: npm run typecheck
63+
4764
- name: Build Astro site
4865
env:
4966
PUBLIC_SITE_URL: https://haber.sametbasbug.dev

‎astro.config.ssr.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function yayinUclari() {
2323
return {
2424
name: 'haber-yayin-uclari',
2525
hooks: {
26+
/** @param {{ injectRoute: (route: { pattern: string, entrypoint: string }) => void }} ctx */
2627
'astro:config:setup': ({ injectRoute }) => {
2728
injectRoute({ pattern: '/api/brief', entrypoint: './src/server/routes/brief.ts' });
2829
injectRoute({ pattern: '/api/publish', entrypoint: './src/server/routes/publish.ts' });

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"build": "astro build",
1919
"build:ssr": "astro build --config astro.config.ssr.mjs",
2020
"deploy": "wrangler deploy --config wrangler.ssr.jsonc",
21+
"typecheck": "tsc --noEmit -p tsconfig.json",
22+
"types:gen": "wrangler types --config wrangler.ssr.jsonc",
2123
"preview": "astro preview",
2224
"astro": "astro",
2325
"ozet:new": "node scripts/new-gunluk-ozet.mjs",
@@ -27,7 +29,7 @@
2729
"haber:ayna": "node scripts/haber-ayna.mjs",
2830
"haber:ayna:kuru": "node scripts/haber-ayna.mjs --kuru",
2931
"test:newsroom": "newsroom/.venv/bin/python -m pytest newsroom/tests",
30-
"quality": "npm run test:newsroom && npm run build"
32+
"quality": "npm run test:newsroom && npm run typecheck && npm run build"
3133
},
3234
"dependencies": {
3335
"@astrojs/markdown-remark": "^7.2.4",

‎tsconfig.json‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
"dist-ssr"
1010
],
1111
"compilerOptions": {
12-
"baseUrl": ".",
12+
// `baseUrl` YOK ve olmamalı: TypeScript 5'ten beri `paths` ona bağlı
13+
// değil, değerler tsconfig'in bulunduğu dizine göre çözülüyor. TS 6'da
14+
// `baseUrl` doğrudan hata veriyordu ve `tsc --noEmit` hiç koşmuyordu —
15+
// yani tür kontrolünün tamamı kapalıydı. Aynı satır TS 7 geçişinin de
16+
// engeliydi.
1317
"paths": {
1418
"#runtime-env": [
15-
"src/data/runtimeEnv.ts"
19+
"./src/data/runtimeEnv.ts"
1620
],
1721
"#news-source": [
18-
"src/data/newsSource.ts"
22+
"./src/data/newsSource.ts"
1923
]
2024
}
2125
}

0 commit comments

Comments
 (0)