'parameters.ts' cannot be compiled under '--isolatedModules'
sneko opened this issue · comments
Hi @fabien0102,
My Typescript linting is complaining with 'parameters.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
. That's because the parameters.ts
is generated empty:
/**
* Generated by @openapi-codegen
*
* @version 0.0.0
*/
My workaround is to append export {}
to make it passes, but it's annoying since it comes back at each generation.
There are multiple solutions:
- In the
openapi-codegen.config.ts
after the generation I override the file automatically if no export detected - I turn off
isolatedModules
in my tsconfig (not a huge fan) - I ignore this file during the linting (not a huge fan)
- See with you if it can be improved 😄
It seems I'm the only one reporting this, maybe I'm doing something wrong?
Thank you,
Just implemented the solution (1) as a quick workaround:
to: async (context) => {
const originalWriteFile = context.writeFile;
context.writeFile = async (file: string, data: string): Promise<void> => {
if (file === 'parameters.ts' && !data.includes('export')) {
data = 'export {}';
}
await originalWriteFile(file, data);
};
const { schemasFiles } = await generateSchemaTypes(context, {});
await generateReactQueryComponents(context, {
schemasFiles,
});
},