How should we organize API type definitions in TypeScript? #875
-
ProblemType definitions for the API are currently spread across the front end code base with inconsistent names and incomplete representation of the API behavior. A fex examples to demonstrate the inconsistency I'm talking about:
Design goals and rationale
Example(I'll use this example throughout the various options below.)
My question is: how do we organize that TS code so that it's easy to add more code for other endpoints, methods, and directions? Discussion formatI'll post separate top-level threads for different options I see, and we can comment on each of them. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Auto-generated typesUse a tool like DRF Typescript generator or similar to generate TypeScript code based on our Python code. I've never done this before. It seems like it could be awesome. But also make a dead end or waste of time if it doesn't pan out as we expect. |
Beta Was this translation helpful? Give feedback.
-
Nested namespaces
Benefits
Drawbacks
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
PascalCasePascalCase
typesmathesar_ui/src/api/tables/constraints.d.ts
mathesar_ui/src/api/index.ts
In a consuming file
Benefits
Drawbacks
/endpoint/foo/
and/endpoint-foo/