New to Drizzle, What have i done wrong? this doesnt feel right

so i have this schema export const tracks = pgTable("tracks", { id: serial("id").primaryKey(), timelineId: integer("timeline_id") .notNull() .references(() => timelines.id, { onDelete: "cascade" }), trackType: varchar("track_type", { length: 20 }).notNull(), order: integer("order").notNull(), name: varchar("name", { length: 200 }), }); i have this function export const createTrack = ( timelineId: number, trackType: string, order: number, name: number ) => { const [newTimeline] = await db .insert(tracks) .values({ timelineId: "hdbhasbjh", trackType, order, name: 999, }) .returning(); return newTimeline; }; at first i accidently typed the wrong type to name but i didnt get any errors in my ide from typescript then i change it to literal number 999 abd also timelineId to a string am i missing something im am confused i though its type safe ?
9 Replies
JustWayne
JustWayne3d ago
Yeah something is not working correctly. I suspect that it's possibly caused by an issue with TS/ESLint or TSConfig.
JustWayne
JustWayne3d ago
When I try to put 999 into a text() field on a pgTable in my project, I get a TS error
No description
JustWayne
JustWayne3d ago
However, you can clearly see what type values() expects when you hover over it. What do you see? Here's what I see for my own table:
No description
Nakumbo
NakumboOP3d ago
o boy i GOD! here my ts config { "extends": "../../tsconfig.base.json", "compilerOptions": { "declaration": true, "declarationMap": true, "sourceMap": true, "outDir": "dist", "composite": true } } my bas ts config { "compilerOptions": { "strict": true, "exactOptionalPropertyTypes": true, "moduleDetection": "force", "composite": true, "downlevelIteration": true, "resolveJsonModule": true, "esModuleInterop": false, "declaration": true, "skipLibCheck": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "moduleResolution": "Bundler", "lib": [ "ES2022", "DOM", "DOM.Iterable" ], "types": [], "isolatedModules": true, "sourceMap": true, "declarationMap": true, "noImplicitReturns": false, "noUnusedLocals": true, "noUnusedParameters": false, "noFallthroughCasesInSwitch": true, "noEmitOnError": false, "noErrorTruncation": false, "allowJs": false, "checkJs": false, "forceConsistentCasingInFileNames": true, "noImplicitAny": true, "noImplicitThis": true, "noUncheckedIndexedAccess": false, "strictNullChecks": true, "baseUrl": ".", "target": "ES2022", "module": "ESNext", "incremental": true, "removeComments": false, "plugins": [ { "name": "@effect/language-service" } ] } } i actually asked ai and couldnt figure it out
JustWayne
JustWayne3d ago
Are you seeing errors in TypeScript-ESLint? Also, I don't see any include setting in your tsconfig e.g. mine has:
"include": [
"./src/",
"../shared/src/"
],
"include": [
"./src/",
"../shared/src/"
],
If you're using VS Code you can do Ctrl+Shift+P and type ESLint to see the commands and run ESLint: Show Output Channel
Nakumbo
NakumboOP3d ago
but this error seem to be coming from a different package not the db package where do you have "include": [ "./src/", "../shared/src/" ], in the base tsconfig??
No description
JustWayne
JustWayne3d ago
No, I put include in the specific tsconfig files, not the base one.
Nakumbo
NakumboOP3d ago
okay i also had a problem with kigrations deleted the folder and regenrate it i dont know if that may cause it fix it thanks
JustWayne
JustWayne3d ago
Excellent

Did you find this page helpful?