Skip to content
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

'parameters.ts' cannot be compiled under '--isolatedModules' #196

Open
sneko opened this issue Aug 23, 2023 · 1 comment
Open

'parameters.ts' cannot be compiled under '--isolatedModules' #196

sneko opened this issue Aug 23, 2023 · 1 comment

Comments

@sneko
Copy link

sneko commented Aug 23, 2023

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:

  1. In the openapi-codegen.config.ts after the generation I override the file automatically if no export detected
  2. I turn off isolatedModules in my tsconfig (not a huge fan)
  3. I ignore this file during the linting (not a huge fan)
  4. 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,

@sneko
Copy link
Author

sneko commented Aug 23, 2023

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,
      });
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant