Is it possible to create schema and
Is it possible to create schema and indexes without typescript?
8 Replies
Schemas are for type-safety and autocompletion - and do require typescript. However, only the schema.ts file needs to be in typescript (everything else can be JS). VSCode should still figure out the autocompletion with that setup. https://docs.convex.dev/using/schemas
Defining a Schema | Convex Developer Hub
End-to-end type safety requires typing your tables.
Indexes currently have the same story, again defined in the schema.ts file.
However we are aware that it's a bit jarring to have to use a ts file in a project that is otherwise js. It's on our radar!
Ok I see, thanks 😊
Note that we currently don't enforce your schema server-side, so the main benefit of defining it is whether you want client-side type safety or if you want to define indexes. Schema enforcement on the server side is coming soon 🙂
and autocomplete (as a benefit of today's schemas)!!
I use Rescript so I don't see how the TS type enforcement could benefit me
The autocompletion benefit would be from doing something like
useQuery("<tab>
- and it will give you a list of your functions in VSCode.
useQuery("myModule:myFunction", <tab
will give you a tabcomplete for the first argument of your function.
I think that should work regardless if you have the .d.ts
files.
But I admit, I haven't tried with rescript. This is mostly in theory in my head.maybe the autocomplet will help while writing the bindings for Rescript