From f4b01d7954c41c50e9f808cc2e34f5f6573312b4 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sun, 30 Jun 2024 20:29:41 -0400 Subject: [PATCH] fix: verbatimModuleSyntax (#953) --- .../2_generator/__snapshots__/files.test.ts.snap | 4 ++-- src/layers/2_generator/code/Error.ts | 12 ++++++------ src/layers/2_generator/code/Select.ts | 4 ++-- src/layers/2_generator/code/global.ts | 2 +- tests/_/schema/generated/Global.ts | 2 +- tests/_/schema/generated/Select.ts | 4 ++-- tests/_/schemaMutationOnly/generated/Global.ts | 2 +- tests/_/schemaMutationOnly/generated/Select.ts | 4 ++-- tests/_/schemaQueryOnly/generated/Global.ts | 2 +- tests/_/schemaQueryOnly/generated/Select.ts | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/layers/2_generator/__snapshots__/files.test.ts.snap b/src/layers/2_generator/__snapshots__/files.test.ts.snap index c0dea2380..0c39cdb7e 100644 --- a/src/layers/2_generator/__snapshots__/files.test.ts.snap +++ b/src/layers/2_generator/__snapshots__/files.test.ts.snap @@ -43,8 +43,8 @@ export const isError = <$Value>(value: $Value): value is Include<$Value, ErrorOb `; exports[`schema2 5`] = ` -"import { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js' -import { Index } from './Index.js' +"import type { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js' +import type { Index } from './Index.js' // Runtime // ------- diff --git a/src/layers/2_generator/code/Error.ts b/src/layers/2_generator/code/Error.ts index 6e4588046..0d203adf2 100644 --- a/src/layers/2_generator/code/Error.ts +++ b/src/layers/2_generator/code/Error.ts @@ -11,14 +11,14 @@ export const { generate: generateError, moduleName: moduleNameError } = createCo ) code.push(` - const ErrorObjectsTypeNameSelectedEnum = { - ${config.error.objects.map(_ => `${_.name}: { __typename: '${_.name}' }`).join(`,\n`)} - } as ${config.error.objects.length > 0 ? `const` : `Record`} + const ErrorObjectsTypeNameSelectedEnum = { + ${config.error.objects.map(_ => `${_.name}: { __typename: '${_.name}' }`).join(`,\n`)} + } as ${config.error.objects.length > 0 ? `const` : `Record`} - const ErrorObjectsTypeNameSelected = Object.values(ErrorObjectsTypeNameSelectedEnum) + const ErrorObjectsTypeNameSelected = Object.values(ErrorObjectsTypeNameSelectedEnum) - type ErrorObjectsTypeNameSelected = (typeof ErrorObjectsTypeNameSelected)[number] - `) + type ErrorObjectsTypeNameSelected = (typeof ErrorObjectsTypeNameSelected)[number] + `) code.push( `export const isError = <$Value>(value:$Value): value is Include<$Value, ErrorObjectsTypeNameSelected> => { diff --git a/src/layers/2_generator/code/Select.ts b/src/layers/2_generator/code/Select.ts index 6164d5615..c79f272e0 100644 --- a/src/layers/2_generator/code/Select.ts +++ b/src/layers/2_generator/code/Select.ts @@ -7,8 +7,8 @@ export const { generate: generateSelect, moduleName: moduleNameSelect } = create (config) => { const code: string[] = [] - code.push(`import { Index } from './${moduleNameIndex}.js'`) - code.push(`import { SelectionSet, ResultSet } from '${config.libraryPaths.schema}'`) + code.push(`import type { Index } from './${moduleNameIndex}.js'`) + code.push(`import type { SelectionSet, ResultSet } from '${config.libraryPaths.schema}'`) code.push(``) code.push( diff --git a/src/layers/2_generator/code/global.ts b/src/layers/2_generator/code/global.ts index 6f2c67f12..8048a59c6 100644 --- a/src/layers/2_generator/code/global.ts +++ b/src/layers/2_generator/code/global.ts @@ -11,7 +11,7 @@ export const { moduleName: moduleNameGlobal, generate: generateGlobal } = create const code: string[] = [] code.push( - `import { Index } from './${moduleNameIndex}.js'`, + `import type { Index } from './${moduleNameIndex}.js'`, ) if (config.typeMapByKind.GraphQLScalarTypeCustom.length > 0) { diff --git a/tests/_/schema/generated/Global.ts b/tests/_/schema/generated/Global.ts index 986787721..9f89d200a 100644 --- a/tests/_/schema/generated/Global.ts +++ b/tests/_/schema/generated/Global.ts @@ -1,4 +1,4 @@ -import { Index } from './Index.js' +import type { Index } from './Index.js' import type * as CustomScalar from '../../customScalarCodecs.js' diff --git a/tests/_/schema/generated/Select.ts b/tests/_/schema/generated/Select.ts index 6216e0471..cedf273ef 100644 --- a/tests/_/schema/generated/Select.ts +++ b/tests/_/schema/generated/Select.ts @@ -1,5 +1,5 @@ -import { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js' -import { Index } from './Index.js' +import type { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js' +import type { Index } from './Index.js' // Runtime // ------- diff --git a/tests/_/schemaMutationOnly/generated/Global.ts b/tests/_/schemaMutationOnly/generated/Global.ts index e3e3c6ad9..e8c2d0a8c 100644 --- a/tests/_/schemaMutationOnly/generated/Global.ts +++ b/tests/_/schemaMutationOnly/generated/Global.ts @@ -1,4 +1,4 @@ -import { Index } from './Index.js' +import type { Index } from './Index.js' declare global { export namespace GraphQLRequestTypes { diff --git a/tests/_/schemaMutationOnly/generated/Select.ts b/tests/_/schemaMutationOnly/generated/Select.ts index c663e3d6c..a0d5ae287 100644 --- a/tests/_/schemaMutationOnly/generated/Select.ts +++ b/tests/_/schemaMutationOnly/generated/Select.ts @@ -1,5 +1,5 @@ -import { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js' -import { Index } from './Index.js' +import type { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js' +import type { Index } from './Index.js' // Runtime // ------- diff --git a/tests/_/schemaQueryOnly/generated/Global.ts b/tests/_/schemaQueryOnly/generated/Global.ts index 2dfd16886..3c915d1d5 100644 --- a/tests/_/schemaQueryOnly/generated/Global.ts +++ b/tests/_/schemaQueryOnly/generated/Global.ts @@ -1,4 +1,4 @@ -import { Index } from './Index.js' +import type { Index } from './Index.js' declare global { export namespace GraphQLRequestTypes { diff --git a/tests/_/schemaQueryOnly/generated/Select.ts b/tests/_/schemaQueryOnly/generated/Select.ts index e1218d233..14a54c19a 100644 --- a/tests/_/schemaQueryOnly/generated/Select.ts +++ b/tests/_/schemaQueryOnly/generated/Select.ts @@ -1,5 +1,5 @@ -import { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js' -import { Index } from './Index.js' +import type { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js' +import type { Index } from './Index.js' // Runtime // -------