feat: warm-up deps — ts-reset, web-vitals, RHF devtool, query-broadcast
Four low-risk adds before the Zod 4 / drizzle-zod headliner: - @total-typescript/ts-reset: tightens TS stdlib types globally (JSON.parse → unknown, fetch().json() → unknown, .filter(Boolean) narrows, Set literals respect typed Set targets). Caught 179 latent type errors; fixed all production sites (8 files) and added `any` cast escape hatch in test files (ESLint exemption scoped to tests/). - web-vitals + /api/v1/internal/vitals endpoint + WebVitalsReporter client component: establishes Core Web Vitals baseline (LCP/INP/CLS/ FCP/TTFB) via navigator.sendBeacon. Required before optimisation work. - @hookform/devtools + FormDevtool wrapper: dev-only RHF state inspector, lazy-loaded via next/dynamic so the chunk is excluded from prod bundles entirely. - @tanstack/query-broadcast-client-experimental: cross-tab cache sync via BroadcastChannel — wired in query-provider.tsx, 1-liner. Audit doc updated with sections 35 + 36 (PDF stack overhaul + comprehensive second-pass package sweep) covering ~20 package adoption candidates and 4-5 deprecation candidates. Verified: tsc clean, vitest 1293/1293 pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,7 +43,7 @@ describe('GET /api/v1/companies/[id]/members', () => {
|
||||
const req = makeMockRequest('GET', `http://localhost/api/v1/companies/${company.id}/members`);
|
||||
const res = await listHandler(req, ctx, { id: company.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(Array.isArray(body.data)).toBe(true);
|
||||
expect(body.data.length).toBe(2);
|
||||
expect(body.data.every((m: { endDate: string | null }) => m.endDate === null)).toBe(true);
|
||||
@@ -81,7 +81,7 @@ describe('GET /api/v1/companies/[id]/members', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const createdBody = await createRes.json();
|
||||
const createdBody = (await createRes.json()) as any;
|
||||
const toEndId = createdBody.data.id as string;
|
||||
|
||||
const delRes = await deleteHandler(
|
||||
@@ -100,7 +100,7 @@ describe('GET /api/v1/companies/[id]/members', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const activeBody = await activeOnlyRes.json();
|
||||
const activeBody = (await activeOnlyRes.json()) as any;
|
||||
expect(activeBody.data.length).toBe(1);
|
||||
|
||||
// activeOnly=false.
|
||||
@@ -112,7 +112,7 @@ describe('GET /api/v1/companies/[id]/members', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const allBody = await allRes.json();
|
||||
const allBody = (await allRes.json()) as any;
|
||||
expect(allBody.data.length).toBe(2);
|
||||
});
|
||||
|
||||
@@ -143,7 +143,7 @@ describe('POST /api/v1/companies/[id]/members', () => {
|
||||
});
|
||||
const res = await createHandler(req, ctx, { id: company.id });
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.companyId).toBe(company.id);
|
||||
expect(body.data.clientId).toBe(client.id);
|
||||
expect(body.data.role).toBe('director');
|
||||
@@ -217,7 +217,7 @@ describe('PATCH /api/v1/companies/[id]/members/[mid]', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const created = (await createRes.json()).data;
|
||||
const created = ((await createRes.json()) as any).data;
|
||||
|
||||
const patchRes = await patchHandler(
|
||||
makeMockRequest(
|
||||
@@ -234,7 +234,7 @@ describe('PATCH /api/v1/companies/[id]/members/[mid]', () => {
|
||||
{ id: company.id, mid: created.id },
|
||||
);
|
||||
expect(patchRes.status).toBe(200);
|
||||
const body = await patchRes.json();
|
||||
const body = (await patchRes.json()) as any;
|
||||
expect(body.data.role).toBe('officer');
|
||||
expect(body.data.notes).toBe('promoted');
|
||||
});
|
||||
@@ -257,7 +257,7 @@ describe('PATCH /api/v1/companies/[id]/members/[mid]', () => {
|
||||
ctxA,
|
||||
{ id: company.id },
|
||||
);
|
||||
const created = (await createRes.json()).data;
|
||||
const created = ((await createRes.json()) as any).data;
|
||||
|
||||
const ctxB = makeMockCtx({ portId: portB.id, permissions: makeFullPermissions() });
|
||||
const patchRes = await patchHandler(
|
||||
@@ -291,7 +291,7 @@ describe('DELETE /api/v1/companies/[id]/members/[mid]', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const created = (await createRes.json()).data;
|
||||
const created = ((await createRes.json()) as any).data;
|
||||
|
||||
const before = new Date();
|
||||
const delRes = await deleteHandler(
|
||||
@@ -329,7 +329,7 @@ describe('DELETE /api/v1/companies/[id]/members/[mid]', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const created = (await createRes.json()).data;
|
||||
const created = ((await createRes.json()) as any).data;
|
||||
|
||||
const explicitEnd = new Date('2026-06-01T00:00:00.000Z');
|
||||
const delRes = await deleteHandler(
|
||||
@@ -373,7 +373,7 @@ describe('POST /api/v1/companies/[id]/members/[mid]/set-primary', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const m1 = (await m1Res.json()).data;
|
||||
const m1 = ((await m1Res.json()) as any).data;
|
||||
|
||||
// M2, M3 — not primary.
|
||||
const m2Res = await createHandler(
|
||||
@@ -387,7 +387,7 @@ describe('POST /api/v1/companies/[id]/members/[mid]/set-primary', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const m2 = (await m2Res.json()).data;
|
||||
const m2 = ((await m2Res.json()) as any).data;
|
||||
|
||||
const m3Res = await createHandler(
|
||||
makeMockRequest('POST', `http://localhost/api/v1/companies/${company.id}/members`, {
|
||||
@@ -400,7 +400,7 @@ describe('POST /api/v1/companies/[id]/members/[mid]/set-primary', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const m3 = (await m3Res.json()).data;
|
||||
const m3 = ((await m3Res.json()) as any).data;
|
||||
|
||||
// Promote M2.
|
||||
const setPrimRes = await setPrimaryHandler(
|
||||
@@ -412,7 +412,7 @@ describe('POST /api/v1/companies/[id]/members/[mid]/set-primary', () => {
|
||||
{ id: company.id, mid: m2.id },
|
||||
);
|
||||
expect(setPrimRes.status).toBe(200);
|
||||
const setPrimBody = await setPrimRes.json();
|
||||
const setPrimBody = (await setPrimRes.json()) as any;
|
||||
expect(setPrimBody.data.id).toBe(m2.id);
|
||||
expect(setPrimBody.data.isPrimary).toBe(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user