blackmann/mangobase

Typescript export should acknowledge `enum`

Closed this issue · 0 comments

When exporting to TS, we should treat string fields with enums as TS string unions.

For example

{ gender: { type: 'string', enum: ['male', 'female'] } }

Translates to:

{ gender: 'male' | 'female' }

Currently it'll just transform to:

{ gender: string }

Related file: https://github.com/blackmann/mangobase/blob/6c863d3b9176326de21ed03295117d7b6ea77290/base/src/lib/export-schema.ts

Add tests here: https://github.com/blackmann/mangobase/blob/2bfae81de382b918943db2e04380bae3f8344faf/base/src/lib/export-schema.test.ts

You'll find the UI for this on the collections page. You don't have to do anything in the UI code.

Screenshot 2023-12-14 at 8 24 53 AM