Open mobob opened 1 week ago
Hi @mobob, thanks for trying it out and providing feedback. The package should be designed to give you native typing with no need for casting, so this is something I'd like to understand why you aren't getting that benefit.
I have a few questions so I can do a better investigation:
Can I just confirm that you're using compatible zod
and dynamodb-onetable
versions? Aka, compatible with zod@^3.23.8
and dynamo-onetable@^2.7.5
.
Can I see the definition of FeedbackRequestSchema
? I wonder if this is caused by some kind of incompatibility. On that note, what happens at that code-snippet at runtime with a logger instance? I baked in a lot of logger.warn
/Error
s for when a zod
type can't be coerced into a dynamodb-onetable
schema.
it('runtime test', () => {
zodOneModelSchema(
FeedbackRequestSchema.extend({
pk: z.literal('FB#${feedbackId}'),
sk: z.literal('TYPE#${_type}#VID#${_vendorListingId}'),
}),
{ logger } // 👈 winston Logger here
)
})
test/zodOneModelSchema.spec.ts
? Those are typing correctly as you expect for me, if they aren't for you it would help me narrow down on testing with different language server protocols.Thanks again for the feedback, I hope I can help out!
@mobob I've pulled this repo into my own VSCode (normally I use nvim
) and IntelliJ Webstorm and the typing seems to be working for me. Looking forward to seeing that FeedbackRequestSchema
is so I can try and do a reproduction of the issue.
Hey! Cool project, i'm a fan of onetable and have been mixing more zod in, so thought i'd give this a go.
I have some zod schema defined in a shared package in my monorepo, so i pull this in, then i added this chunk into my mega one table schema:
The casting to OneModel seemed necessary, it really broke the bounds of the overall structure without it.
And then further down i have a type for this entity:
However, when i try to use this (hover in vscode), it shows the type of these Entity objects is pretty unknown:
Whereas hovering over a different type that is not defined with zod and more explitily, you see all the bits, ie:
Is there any way to make this less opaque?
If you have any pointers let me know!