Is it possible to define the structure of an object in TypeScript, which can then be used as a parameter type?
What I mean:
I have (say) 5 functions that return the same structure of an object, for example:
foo(): { bar: string, baz: boolean, idk: number } { ... } bar(): { bar: string, baz: boolean, idk: number } { ... } ...
the problem is that I have to define this structure for every function that returns such an object.
So is it possible to do something like the following?
declare const OBJECT_STRUCTURE: { bar: string, baz: boolean, idk: number } foo(): OBJECT_STRUCTURE { ... } bar(): OBJECT_STRUCTURE { ... } ...
source share