daily-code icon indicating copy to clipboard operation
daily-code copied to clipboard

Fix TypeScript compilation error in seed script

Open TanmayDhobale opened this issue 10 months ago • 3 comments

Description: This pull request resolves a TypeScript compilation error encountered while running the seed script. The error occurred due to missing properties in the seed data object passed to Prisma.

Changes:

Added missing sortingOrder property to the seed data object to align with the requirements of the TrackProblems model in Prisma. Details:

Updated the prisma/seed.ts file to include the sortingOrder property in the seed data object. Verified that the TypeScript compilation error is resolved and the seed script runs successfully.

before -

Screenshot 2567-04-10 at 11 22 37 AM

after -

Screenshot 2567-04-10 at 11 23 33 AM

TanmayDhobale avatar Apr 10 '24 05:04 TanmayDhobale

Simulated seeding without the sortingOrder property to confirm the error message. Expected Error Message (if sortingOrder is omitted during seeding):

prisma/seed.ts:10:9 - error TS2322: Type '{ problem: { create: { title: string; description: string; notionDocId: string; type: "Blog"; }; }; }' is not assignable to type '(Without<TrackProblemsCreateWithoutTrackInput, TrackProblemsUncheckedCreateWithoutTrackInput> & TrackProblemsUncheckedCreateWithoutTrackInput) | (Without<...> & TrackProblemsCreateWithoutTrackInput) | TrackProblemsCreateWithoutTrackInput[] | TrackProblemsUncheckedCreateWithoutTrackInput[] | undefined'.
  Type '{ problem: { create: { title: string; description: string; notionDocId: string; type: "Blog"; }; }; }' is not assignable to type 'Without<TrackProblemsUncheckedCreateWithoutTrackInput, TrackProblemsCreateWithoutTrackInput> & TrackProblemsCreateWithoutTrackInput'.
    Property 'sortingOrder' is missing in type '{ problem: { create: { title: string; description: string; notionDocId: string; type: "Blog"; }; }; }' but required in type 'TrackProblemsCreateWithoutTrackInput'.

TanmayDhobale avatar Apr 10 '24 06:04 TanmayDhobale

I think that in the future, we should not need the seed file, itself. Although you could have also copied migrate.ts to seed.ts to make the seed work just fine in your local dev environment.

Neon-20 avatar Apr 10 '24 06:04 Neon-20

I think that in the future, we should not need the seed file, itself. Although you could have also copied migrate.ts to seed.ts to make the seed work just fine in your local dev environment.

Having a seed file helps newcomers understand seed how we start with data in our project and keeps everyone's development environments consistent

TanmayDhobale avatar Apr 10 '24 08:04 TanmayDhobale