Use typescript types in Pack Builder?

I am fetching to my own API, and returning a deeply nested structure (arrays of objects within arrays of objects).

I have a typescript type than I can easily copy and paste into the pack builder.

Can coda pack builder use this type?

You mean convert typescript types to Coda schema objects?

I don’t know of such capability but it sounds like an interesting tool to develop — I found it myself several times that it was too tedious to manually create schema objects for my data that I already declared as TS types.

@Eric_Koleda maybe there’s a way I don’t know about?

That’s right! To infer a coda Schema from a typescript type.

Thanks @Paul_Danyliuk

Woah! I haven’t tested it yet, but this pack looks promising

Edit: it works well enough! For a base shape.

Better would be: declaring a typescript type inside a pack (or importing it from an npm package), and providing it to some coda helper that infers an object schema. In a way where I could still extend the inferred coda object schema, e.g. to add sync table properties for example.

1 Like

Hi @Michael_McGreal - I’ve had the same wish, as it can feel duplicative to define the structure twice. I think the core blocker is that TypeScript types don’t exist at runtime, they are just a compile-time feature. There seems to be some newer TypeScript reflection libraries out there (example) that you could experiment with, and if you get something working let us know!

2 Likes