fredericbarthelet / typebridge

Typescript toolbox for AWS EventBridge
76 stars 10 forks source link

⬆️ Upgrade json-schema-to-ts version #15

Closed ThomasAribart closed 2 years ago

ThomasAribart commented 2 years ago

Hi @fredericbarthelet 👋

Since v2, json-schema-to-ts now supports an option as secondary input. For the moment, TypeBridge doesn't give the possibility to hydrate such options. I see two possibilities to fix that:

  1. Give the possibility to hydrate such options with generic types
const myEvent = new Event<"EVENT_NAME", typeof mySchema, FromSchemaOptions>({...})
  1. Give the possibility to override the inferred type with an overlay
type MyOverlay = {
  name: string
}

const myEvent = new Event<MyOverlay, "EVENT_NAME">({...}) // <= Is hard-typing the event name really useful ?

// This way the users can re-use FromSchema with custom options in the Overlay
const myEvent = new Event<FromSchema<typeof mySchema, CustomOptions>, "EVENT_NAME">({...})

WDYT ?