How to create type safe flow using msw/data? #1726
Replies: 2 comments 1 reply
-
Hi, @timsofteng. Thanks for raising this. I agree. We can certainly improve in providing more recipes that feature MSW + Data, especially when it comes to correct TypeScript usage. So far, I've written Type-safe API mocking with MSW and TypeScript that goes through common ways to use the library with TypeScript but it doesn't feature ecosystem packages like Data. In the Data announcement post, I've also created a couple of sandboxes that feature the integration between the libraries but I believe they use plain JavaScript so no type examples there either. I will keep this in mind for the future. There's likely major changes coming to Data sometime next year, including the improved TypeScript support (like the generic support on the |
Beta Was this translation helpful? Give feedback.
-
@kettanaito thanks for the reply. Yeah I read these articles and they are quite useful. However they don't cover the gap which I've mentioned. The main problem is in stacking output type from factory's methods with input generic types of rest methods. I cannot property type them to work together with each other. |
Beta Was this translation helpful? Give feedback.
-
Hello. As far as I know
rest[handler]
utils can consume some generics including resp type. The problem isfactory
from msw data package return its own internal type when I try get some value with db.myTable.getAll() or whatever. It would be cool to see some recipes and examples how to use these tools together with typescript.Thanks.
Beta Was this translation helpful? Give feedback.
All reactions