-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript Support for Generated Mocks #48
Comments
I'm not sure if I agree here. Don't get me wrong, I love TypeScript. But generated files should probably rather get ignored instead of linted (or formatted). Every user has a different lint configuration and there will probably always be a rule that is too strict for the generated file. I think it's not reasonable, or even possible, to write the output file in a way that every possible linting rule is happy. Maybe consider ignoring the generated files in your eslint config, instead. |
The types of the internal structure can be declare module '@/mock/handlers' {
import { rest } from 'msw';
export const handlers: rest.RequestHandler[];
} This way we don't get the error about type definitions when importing the handlers |
please do it |
For our organization use case, we usually generate the mocks by running
npx msw-auto-mock ./swagger.json -o ./src/generated/mock.ts --base-url ${BASE_URL} --codes 200,201,204
If we don't ingnore eslint for this file, we always end up with the following complaint.
I'd propose another new
option('-s, --typescript', 'Generate TypeScript code.')
for generating more strict typed mocks. If it is a good idea, I'd like to help get a PR done as well.The text was updated successfully, but these errors were encountered: