Repository navigation
Conversation
`EXTENSION_TO_PARSER` had `ts` and `tsx` but not `mts` or `cts`, so an `outputFile` ending in `.mts` or `.cts` got no parser and `prettier.format` threw `UndefinedParserError` before the file was written.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
@reduxjs/rtk-codemods
@rtk-query/codegen-openapi
@rtk-query/graphql-request-base-query
@reduxjs/toolkit
commit: |
Setting
outputFileto something like./api.mtsor./api.ctsmakes the codegen throw instead of writing the file:prettifypicks the parser from the output file's extension, andEXTENSION_TO_PARSERonly knowstsandtsxon the TypeScript side:So for
mts/ctsthe parser isundefined, Prettier gets neither a parser nor a file path, and it throws beforefs.writeFileSyncruns. This addsmtsandctsnext tots, both mapped to'typescript'. I didn't addmjs/cjs, since the generated code is TypeScript either way. Unknown extensions still throw, like the@throwsonprettifysays.No issue for this one. It only takes a plain config to hit:
outputFileaccepts any path, and the package already supports.mtsAPI files underesmExtensions.The new
test.each(['mts', 'cts'])ingenerateEndpoints.test.tsgenerates the same options toout.tsandout.<ext>and expects identical files. Both fail on master with theUndefinedParserErrorand pass here. All 132 codegen tests pass, with no type errors.