Skip to content

Commit d9877b3

Browse files
strideraclaude
andcommitted
fix: unix-crypt-td-js import for SWC CJS interop
SWC gives the function directly with `import * as`, but tsc sees a namespace object. Use a type cast to bridge the mismatch. Reverts the default import that caused `crypt.default is not a function` at runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bb4e9c7 commit d9877b3

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

apps/api/src/characters/characters.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import { ConfigService } from '@nestjs/config';
1010
import * as bcrypt from 'bcrypt';
1111
import * as crypto from 'crypto';
1212
import Redis from 'ioredis';
13-
import crypt from 'unix-crypt-td-js';
13+
// SWC CJS interop: import * gives the function directly at runtime,
14+
// but tsc sees it as { default: fn }. Cast to reconcile.
15+
import * as _crypt from 'unix-crypt-td-js';
16+
const crypt = _crypt as unknown as (password: string, salt: string) => string;
1417
import type { ItemInstanceFlag, Prisma } from '@muditor/db';
1518
import { DatabaseService } from '../database/database.service';
1619
import { RoleCalculatorService } from '../users/services/role-calculator.service';
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
declare module 'unix-crypt-td-js' {
2-
function crypt(password: string, salt: string): string;
3-
export = crypt;
2+
export default function crypt(password: string, salt: string): string;
43
}

0 commit comments

Comments
 (0)