Skip to content

Commit

Permalink
fix(duckdb): try fix typecheck (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonNekoGH authored Feb 28, 2025
1 parent d1b4b0a commit 184cfdc
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
14 changes: 14 additions & 0 deletions apps/stage-tamagotchi/src/renderer/src/worker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare module '*.js?url' {
const content: string
export default content
}

declare module '*.wasm?url' {
const content: string
export default content
}

declare module '*.cjs?url' {
const content: string
export default content
}
3 changes: 3 additions & 0 deletions packages/drizzle-duckdb-wasm/src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ export function drizzle<
if (typeof connection === 'string')
return constructByDSN(connection, drizzleConfig) as any

if (typeof connection === 'undefined')
throw new Error('connection option is required')

return construct(connect({
bundles: connection.bundles,
logger: connection.logger,
Expand Down
7 changes: 4 additions & 3 deletions packages/drizzle-duckdb-wasm/src/dsn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export function parseDSN(dsn: string): StructuredDSN {
structured.bundles = 'import-url'
}

if (isLiterallyTrue(parsed.searchParams.get('logger'))) {
const paramLogger = parsed.searchParams.get('logger')
if (paramLogger && isLiterallyTrue(paramLogger)) {
structured.logger = true
}

Expand All @@ -57,9 +58,9 @@ export function parseDSN(dsn: string): StructuredDSN {
structured.storage = {
type: DBStorageType.ORIGIN_PRIVATE_FS,
path: parsed.pathname.startsWith('/') ? parsed.pathname.slice(1) : parsed.pathname,
...isLiterallyTrue(paramWrite) && {
...(paramWrite && isLiterallyTrue(paramWrite) && {
accessMode: DuckDBAccessMode.READ_WRITE,
},
}),
}
break
}
Expand Down
4 changes: 2 additions & 2 deletions packages/drizzle-duckdb-wasm/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class DuckDBWasmSession<
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(
query: Query,
fields: SelectedFieldsOrdered | undefined,
name: string | undefined,
isResponseInArrayMode: boolean,
_name: string | undefined,
_isResponseInArrayMode: boolean,
customResultMapper?: (rows: unknown[][]) => T['execute'],
): PgPreparedQuery<T> {
return new DuckDBWASMPreparedQuery(
Expand Down
2 changes: 1 addition & 1 deletion packages/duckdb-wasm/src/duckdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface DuckDBWasmClient {
db: AsyncDuckDB
conn: AsyncDuckDBConnection
close: () => Promise<void>
query: (string, params?: unknown[]) => Promise<Record<string, unknown>[]>
query: (query: string, params?: unknown[]) => Promise<Record<string, unknown>[]>
}

export async function connect(options: ConnectOptions): Promise<DuckDBWasmClient> {
Expand Down
2 changes: 1 addition & 1 deletion packages/duckdb-wasm/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function parseInterval(arr: Int32Array) {
const years = arr[0]
const months = arr[1]

const result = []
const result: string[] = []
if (years !== 0) {
result.push(`${years} year${years > 1 ? 's' : ''}`)
}
Expand Down

0 comments on commit 184cfdc

Please sign in to comment.