Gorka Cesium
Gorka Cesium•3y ago

Is it possible to create schema and

Is it possible to create schema and indexes without typescript?
8 Replies
nipunn
nipunn•3y ago
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.
nipunn
nipunn•3y ago
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!
Gorka Cesium
Gorka CesiumOP•3y ago
Ok I see, thanks 😊
james
james•3y ago
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 🙂
nipunn
nipunn•3y ago
and autocomplete (as a benefit of today's schemas)!!
Gorka Cesium
Gorka CesiumOP•3y ago
I use Rescript so I don't see how the TS type enforcement could benefit me
nipunn
nipunn•3y ago
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.
Gorka Cesium
Gorka CesiumOP•3y ago
maybe the autocomplet will help while writing the bindings for Rescript

Did you find this page helpful?