Skip to content

Commit 86fa2b0

Browse files
wmaddenclaude
andcommitted
chore(cli): replace remaining bare as casts with blindCast (PR#746)
Clean up as we go — CodeRabbit flagged these in R5; I'd dismissed them as pre-existing (they predate this PR), but per repo policy bare `as` should not exist in production code. Three sites: the two `notOk(failure) as DbInitResult | DbUpdateResult` widenings in db-run.ts (failure-path return) and the `projectedSchema as never` opaque-IR pass-through in db-verify.ts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Will Madden <madden@prisma.io>
1 parent 8c74109 commit 86fa2b0

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

packages/1-framework/3-tooling/cli/src/control-api/operations/db-run.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
type PlannerError,
2222
planMigration,
2323
} from '@prisma-next/migration-tools/aggregate';
24+
import { blindCast } from '@prisma-next/utils/casts';
2425
import { ifDefined } from '@prisma-next/utils/defined';
2526
import { notOk, ok } from '@prisma-next/utils/result';
2627
import { CliStructuredError } from '../../utils/cli-errors';
@@ -332,7 +333,10 @@ function mapPlannerError(error: PlannerError): DbInitResult | DbUpdateResult {
332333
why: undefined,
333334
meta: undefined,
334335
};
335-
return notOk(failure) as DbInitResult | DbUpdateResult;
336+
return blindCast<
337+
DbInitResult | DbUpdateResult,
338+
'notOk(failure) is shape-compatible with both DbInitResult and DbUpdateResult; the union is the return type of the surrounding function'
339+
>(notOk(failure));
336340
}
337341
if (error.kind === 'extensionPathUnreachable') {
338342
return buildRunnerFailure({
@@ -427,5 +431,8 @@ function buildRunnerFailure(args: {
427431
conflicts: undefined,
428432
...ifDefined('warnings', args.warnings),
429433
};
430-
return notOk(failure) as DbInitResult | DbUpdateResult;
434+
return blindCast<
435+
DbInitResult | DbUpdateResult,
436+
'notOk(failure) is shape-compatible with both DbInitResult and DbUpdateResult; the union is the return type of the surrounding function'
437+
>(notOk(failure));
431438
}

packages/1-framework/3-tooling/cli/src/control-api/operations/db-verify.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
type VerifierOutput,
1414
verifyMigration,
1515
} from '@prisma-next/migration-tools/aggregate';
16-
import { castAs } from '@prisma-next/utils/casts';
16+
import { blindCast, castAs } from '@prisma-next/utils/casts';
1717
import { notOk, ok, type Result } from '@prisma-next/utils/result';
1818
import { CliStructuredError } from '../../utils/cli-errors';
1919
import {
@@ -186,7 +186,10 @@ export function createPerMemberVerifier<TFamilyId extends string, TTargetId exte
186186
// The family's `TSchemaIR` is opaque to migration-tools; the
187187
// aggregate verifier passes through whatever we hand it. The
188188
// family expects its own IR shape on the way back.
189-
schema: projectedSchema as never,
189+
schema: blindCast<
190+
never,
191+
'family TSchemaIR is opaque to migration-tools; projectedSchema is passed straight through'
192+
>(projectedSchema),
190193
strict: verifyMode === 'strict',
191194
frameworkComponents,
192195
});

0 commit comments

Comments
 (0)