nextcloud / tables

🍱 Nextcloud tables app
https://apps.nextcloud.com/apps/tables
GNU Affero General Public License v3.0
143 stars 24 forks source link

Generate typescript definitions from openapi spec #799

Open juliushaertl opened 8 months ago

juliushaertl commented 8 months ago

As @enjeck brought up it is quite hard to work with a yet unfamiliar code base that has complex data structures as the tables app, so we thought that the openapi spec could be used to automatically generate typescript definitions.

While rolling out typescript in general is probably worth a general discussion and an iterative process, using https://www.npmjs.com/package/openapi-typescript seems to be able to generate a somewhat reasonable definition file:

npx openapi-typescript ./openapi.json -o ./src/schema.d.ts

We should see if:

enjeck commented 8 months ago

this can be used as jsdoc annotations to get proper IDE type hints

I tried doing something like this. I created a new file with typedefs for Tables, Columns and others. Imported these types into other files, and it was kinda helpful.

The problem now might be VS Code not integrating well with Vue? For example, suppose there is a component, having a prop named columns under props. The columns prop doesn't get referenced when when I use it (via this.columns) under the data, computed and methods option. Wondering if using a specific IDE or extension helps with this. If I could fix this, I'll be very happy