https://pact.io logo
#general
Title
# general
b

Bernard Baker

05/09/2022, 10:57 AM
👋 feature question/request from one of our engineers: Could Pact generate TypeScript bindings automatically?
y

Yousaf Nabi (pactflow.io)

05/09/2022, 11:07 AM
I have seen a package attempting it the other way round https://github.com/HLTech/pact-gen-ts
This project aims to create a package that can generate pact files only from TypeScript definitions (without the necessity of writing separated tests with using pact-js package).
but haven't used this yet, so cannot comment on its usefulness. On Pact -> TS Bindings, how do you mean? We use TS interfaces for say a Product interface and we use those interfaces in the pact interaction builder, so we get intellisense typing.
But if you have created a pact file you already have a client so I'm not sure how useful that would be?
Yep the Pact file would come after the interaction with the client, so it's a bit of a weird trip, you need to build up your req/res in the pact interaction, and make it in your client code, so you should have an interface. You can generate types/clients from your providers spec (oas) with tools I've seen in the wild
b

Boris

05/10/2022, 5:50 AM
I guess it might make more sense from a BDC perspective, but there are probably other tools for that already 🤔
3 Views