Skip to content

fix(drizzle): add missing closing parenthesis in D1 getDb function#1022

Merged
jycouet merged 2 commits intosveltejs:mainfrom
tknkaa:fix-drizzle-d1-syntax-error
Apr 1, 2026
Merged

fix(drizzle): add missing closing parenthesis in D1 getDb function#1022
jycouet merged 2 commits intosveltejs:mainfrom
tknkaa:fix-drizzle-d1-syntax-error

Conversation

@tknkaa
Copy link
Copy Markdown
Contributor

@tknkaa tknkaa commented Apr 1, 2026

Closes #1021

Description

When generating the database client file for Cloudflare D1, the template string was missing a closing parenthesis in the arrow function parameter, resulting in invalid TypeScript syntax.

This caused the parser to fail with 'Unexpected token' error during project creation when using the drizzle addon with D1 database option.

Changed:
export const getDb = (d1: D1Database => drizzle(d1, { schema });
To:
export const getDb = (d1: D1Database) => drizzle(d1, { schema });

Fixes the error: Unable to process 'src/lib/server/db/index.ts'. Reason: Unexpected token

Checklist

  • Update snapshots (if applicable)
  • Add a changeset (if applicable)
  • Allow maintainers to edit this PR
  • I care about what I'm doing, no matter the tool I use (Notepad, Sublime, VSCode, AI...)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

🦋 Changeset detected

Latest commit: 16a87d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sv Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot
Copy link
Copy Markdown

1 similar comment
@svelte-docs-bot
Copy link
Copy Markdown

When generating the database client file for Cloudflare D1, the template
string was missing a closing parenthesis in the arrow function parameter,
resulting in invalid TypeScript syntax.

This caused the parser to fail with 'Unexpected token' error during project
creation when using the drizzle addon with D1 database option.

Changed:
  export const getDb = (d1: D1Database => drizzle(d1, { schema });
To:
  export const getDb = (d1: D1Database) => drizzle(d1, { schema });

Fixes the error: Unable to process 'src/lib/server/db/index.ts'. Reason: Unexpected token
@tknkaa tknkaa force-pushed the fix-drizzle-d1-syntax-error branch from 9f6e8fc to 1054068 Compare April 1, 2026 09:59
@jycouet
Copy link
Copy Markdown
Contributor

jycouet commented Apr 1, 2026

Thx for fixing it.
Could you add a changeset ? Thx

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 1, 2026

Open in StackBlitz

npx https://pkg.pr.new/svelte-migrate@1022
npx https://pkg.pr.new/sv@1022
npx https://pkg.pr.new/@sveltejs/sv-utils@1022

commit: 16a87d9

@jycouet jycouet merged commit d3304af into sveltejs:main Apr 1, 2026
8 checks passed
@github-actions github-actions bot mentioned this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] drizzle addon fails with "Unexpected token" when creating a project with Cloudflare D1

2 participants