-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Report hasn't been filed before.
- I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm
are you using?
0.44.5
What version of drizzle-kit
are you using?
0.31.4
Other packages
drizzle-zod@0.7.0
Describe the Bug
What is the undesired behavior?
When defining an enum column from an existing object, a type error occurs and drizzle-kit generate
fails.
The TypeScript error:
Type string[] is not assignable to type [string, ...string[]]
The drizzle-kit generate
error:
Error [ERR_REQUIRE_ASYNC_MODULE]: require() cannot be used on an ESM graph with top-level await. Use import() instead. To see where the top-level await comes from, use --experimental-print-required-tla.
From C:\Project\src\utils\cognito.ts
Requiring C:\Project\node_modules\sst\node\config\index.js
at ModuleJobSync.runSync (node:internal/modules/esm/module_job:476:13)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:435:47)
at loadESMFromCJS (node:internal/modules/cjs/loader:1565:24)
at Module._compile (node:internal/modules/cjs/loader:1716:5)
at node:internal/modules/cjs/loader:1899:10
at newLoader (C:\Project\node_modules\drizzle-kit\bin.cjs:14317:13)
at Object.newLoader (C:\Project\node_modules\drizzle-kit\bin.cjs:14317:13)
at extensions..js (C:\Project\node_modules\drizzle-kit\bin.cjs:16840:28)
at Module.load (node:internal/modules/cjs/loader:1469:32)
at Module._load (node:internal/modules/cjs/loader:1286:12) {
code: 'ERR_REQUIRE_ASYNC_MODULE'
}
What are the steps to reproduce it?
const UserStatus = {
Confirmed,
Unconfirmed,
} as const;
export const accountsSchema = pgSchema('accounts');
export const users = accountsSchema.table(
'users',
{
id: uuid('id').defaultRandom().primaryKey(),
status: text('status', {
enum: Object.keys(UserStatus), // returns ['Confirmed', 'Unconfirmed'] but has type error
// enum: ['Confirmed', 'Unconfirmed'], // this works
}),
}
);
What is the desired result?
Change the enum
type to string[]
or to also accept string[]
.
What database engine are you using? Are you using a specific cloud provider? Which one?
drizzle-orm/aws-data-api/pg
If this is a bug related to types: What Typescript version are you using? What's the content of your tsconfig.json file?
typescript@5.9.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working