Skip to content

Conversation

@bitgopatmcl
Copy link
Contributor

Some packages define custom codecs (as in they aren't built up from the io-ts combinators) or import them from external libraries. Currently, we define several of these in the knownImports.ts file, but it is impossible to include all of them, or ones that are from private packages. This change adds a --codec-file option that'll read a js file's default export and add it to the hardcoded set of known imports. To avoid issues with importing fp-ts/Either in this config file, the default export should actually be a function that accepts E, and returns the set of additional known codecs, like so:

module.exports = (E) => {
  return {
    'my-custom-codecs': {
      foo: () => E.right({ type: 'object', properties: {}, required: [] })
    }
  }
}

I'm not in love with how this works, but haven't been able to think of a better way to support custom defined codecs without needing to bring in a full typechecker to read their output types.

@bitgopatmcl bitgopatmcl requested a review from a team as a code owner September 1, 2023 14:40
@ericcrosson-bitgo ericcrosson-bitgo merged commit f644b1c into BitGo:master Sep 1, 2023
@github-actions
Copy link

github-actions bot commented Sep 1, 2023

🎉 This PR is included in version @api-ts/openapi-generator@2.4.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@bitgopatmcl bitgopatmcl deleted the custom-known-imports branch September 1, 2023 18:39
@github-actions
Copy link

🎉 This PR is included in version @api-ts/typed-express-router@1.1.1 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version @api-ts/express-wrapper@1.0.21 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version @api-ts/superagent-wrapper@1.1.12 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Oct 4, 2023

🎉 This PR is included in version @api-ts/io-ts-http@2.4.1-beta.1 🎉

The release is available on @api-ts/io-ts-http

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants