get-convex / convex-demos

Demo apps built on Convex.
https://docs.convex.dev/
171 stars 25 forks source link

defining two tables in schema produces type errors #28

Closed suhasdeshpande closed 8 months ago

suhasdeshpande commented 9 months ago

My schema.ts file


export default defineSchema({
    foo: defineTable({
        foo_property: v.string()
    }),
    bar: defineTable({
        bar_property: v.string()
    })
});

my convex fn

export const createBar = mutation({
    args: {
      bar_property: v.string()
    },
    handler: async (ctx, args) => {
        await ctx.db.insert("bar", {
            bar_property: args.bar_property
        });
    }
});

adding bar_property in insert complains with Object literal may only specify known properties, and 'bar_property' does not exist in type '{ foo_property: string;}'

nipunn1313 commented 9 months ago

Hello. I tried to repro, and cannot. Your code looks good and seems to run when I try it. I get no complaints from typescript.

image

image

Can you be more precise with repro steps? It seems like your code is good. The error almost looks like you're running tsc against an old version of the code? Did you hit save?

nipunn1313 commented 9 months ago

It's also possible that you hit save, but didn't run npx convex dev in the terminal, so the generated typescript bindings may not have updated from an older version of your code. If you're still unable to resolve, if you're willing to zip/tar up your folder and send it over, that could help debug further.

suhasdeshpande commented 9 months ago

I hit save, I removed the generated code and re-ran the convex dev command

nipunn1313 commented 9 months ago

It sounds like you hit save, removed generated code and re-ran the dev command, making sure you're starting from a clean slate. Are you still seeing the issue?

suhasdeshpande commented 9 months ago

yea unfortunately still facing the issue.

nipunn1313 commented 9 months ago

If you're willing to zip/tar up your folder and send it over, and provide repro steps that could help debug further.

suhasdeshpande commented 8 months ago

Thanks. Sorry for delay and back and forth.. I was able to get it to work after cleaning up the generated files and giving tsc enough time to come to its senses. I am loving the tool and having a lot of fun building with it.

nipunn1313 commented 8 months ago

Glad you were able to get things resolved!!

Happy hacking. Appreciate the kind words