SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

[TypeScript] spacetime generate should generate .js files, not .ts

Open bfops opened this issue 1 year ago • 0 comments

If a user is working with a non-typescript project, they simply cannot use the bindings generated by spacetimedb. Hence, we should generate .js files as bindings. We can type the files in 2 ways:

  • JSDoc: JSDoc are types-in-comments, and work well too!
  • .js + .d.ts: THis will be a bit more complicated, but it requires generating 2 files, .js with all the logic, and .d.ts with the correct types specified, TypeScript will automatically combine the two while checking.

Best of both worlds

We scan through user's files and if we see .ts files, we generate .ts by default. Otherwise switch to .js(or .js+.d.ts). Can be overriden by a CLI flag (--use-typescript)

bfops avatar Nov 08 '24 23:11 bfops