cometkim / gatsby-plugin-typegen

Let's give developers using GatsbyJS better DX with extreme type-safety

Home Page:https://www.gatsbyjs.org/packages/gatsby-plugin-typegen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why noExport default options set true..?

youngrove opened this issue · comments

Issue

  • useStaticQuery auto fixed but default export options set noExport.

My auto generated types is here..

// no export 
declare namespace GatsbyTypes {
...

But, I can't use GatsbyTypes for My query.
Screen Shot 2022-01-30 at 7 24 16 PM

In codegen.ts

const DEFAULT_TYPESCRIPT_CONFIG: Readonly<TypeScriptPluginConfig> = {
  avoidOptionals: true,
  immutableTypes: true,
  maybeValue: 'T | undefined',
  noExport: true,
  enumsAsTypes: true,
};

I added this line when I used generated types...

/// <reference path = "../__generated__/gatsby-types.ts" />

And I Got this error. I Knew If I change ts.config file It will resolved..
But I wonder why set default noexport options set true..

'gatsby-types.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.

As you can see, the codegen output doesn't use any module output, but just declare the global namespace GatsbyTypes.

This may be incompatible with the --isolatedModules, so you can explicitly mark it as *.d.ts if needed.