refactor: add importsNotUsedAsValues: error to force import type (#872)

This commit is contained in:
Tim Griesser 2021-03-27 16:26:13 -04:00 committed by GitHub
parent a59273de88
commit 74c93e2ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 153 additions and 137 deletions

View File

@ -1,4 +1,4 @@
import * as ts from 'typescript'
import type * as ts from 'typescript'
export interface ContextType {
source: ts.SourceFile

View File

@ -42,7 +42,7 @@ import {
isWrappingType,
printSchema,
} from 'graphql'
import { ArgsRecord, NexusFinalArgConfig } from './definitions/args'
import type { ArgsRecord, NexusFinalArgConfig } from './definitions/args'
import {
InputDefinitionBlock,
NexusInputFieldDef,
@ -50,10 +50,10 @@ import {
NexusOutputFieldDef,
OutputDefinitionBlock,
} from './definitions/definitionBlocks'
import { NexusEnumTypeConfig } from './definitions/enumType'
import { NexusExtendInputTypeConfig, NexusExtendInputTypeDef } from './definitions/extendInputType'
import { NexusExtendTypeConfig, NexusExtendTypeDef } from './definitions/extendType'
import { NexusInputObjectTypeConfig } from './definitions/inputObjectType'
import type { NexusEnumTypeConfig } from './definitions/enumType'
import type { NexusExtendInputTypeConfig, NexusExtendInputTypeDef } from './definitions/extendInputType'
import type { NexusExtendTypeConfig, NexusExtendTypeDef } from './definitions/extendType'
import type { NexusInputObjectTypeConfig } from './definitions/inputObjectType'
import {
FieldModificationDef,
Implemented,
@ -62,7 +62,7 @@ import {
NexusInterfaceTypeDef,
} from './definitions/interfaceType'
import { NexusObjectTypeConfig, NexusObjectTypeDef, ObjectDefinitionBlock } from './definitions/objectType'
import { NexusScalarTypeConfig } from './definitions/scalarType'
import type { NexusScalarTypeConfig } from './definitions/scalarType'
import { NexusUnionTypeConfig, UnionDefinitionBlock, UnionMembers } from './definitions/unionType'
import {
AllNexusArgsDefs,
@ -91,7 +91,7 @@ import {
unwrapGraphQLDef,
unwrapNexusDef,
} from './definitions/wrapping'
import {
import type {
MissingType,
NexusFeaturesInput,
NexusGraphQLFieldConfig,
@ -103,8 +103,8 @@ import {
SourceTypings,
TypingImport,
} from './definitions/_types'
import { DynamicInputMethodDef, DynamicOutputMethodDef } from './dynamicMethod'
import { DynamicOutputPropertyDef } from './dynamicProperty'
import type { DynamicInputMethodDef, DynamicOutputMethodDef } from './dynamicMethod'
import type { DynamicOutputPropertyDef } from './dynamicProperty'
import {
NexusFieldExtension,
NexusInputObjectTypeExtension,
@ -123,12 +123,12 @@ import {
} from './plugin'
import { declarativeWrappingPlugin } from './plugins'
import { fieldAuthorizePlugin } from './plugins/fieldAuthorizePlugin'
import { SourceTypesConfigOptions } from './typegenAutoConfig'
import { TypegenFormatFn } from './typegenFormatPrettier'
import type { SourceTypesConfigOptions } from './typegenAutoConfig'
import type { TypegenFormatFn } from './typegenFormatPrettier'
import { TypegenMetadata } from './typegenMetadata'
import { AbstractTypeResolver, GetGen } from './typegenTypeHelpers'
import type { AbstractTypeResolver, GetGen } from './typegenTypeHelpers'
import { resolveTypegenConfig } from './typegenUtils'
import { RequiredDeeply } from './typeHelpersInternal'
import type { RequiredDeeply } from './typeHelpersInternal'
import {
assertNoMissingTypes,
casesHandled,

View File

@ -1,4 +1,4 @@
import {
import type {
GraphQLCompositeType,
GraphQLEnumType,
GraphQLFieldConfig,
@ -13,17 +13,17 @@ import {
GraphQLSchema,
GraphQLUnionType,
} from 'graphql'
import {
import type {
NexusFieldExtension,
NexusInputObjectTypeExtension,
NexusInterfaceTypeExtension,
NexusObjectTypeExtension,
NexusSchemaExtension,
} from '../extensions'
import * as AbstractTypes from '../typegenAbstractTypes'
import { RequiredDeeply } from '../typeHelpersInternal'
import type * as AbstractTypes from '../typegenAbstractTypes'
import type { RequiredDeeply } from '../typeHelpersInternal'
export { AbstractTypes }
export type { AbstractTypes }
export type Maybe<T> = T | null

View File

@ -1,6 +1,6 @@
import { GraphQLScalarTypeConfig } from 'graphql'
import { AllInputTypes, GetGen2 } from '../typegenTypeHelpers'
import { AllNexusArgsDefs, AllNexusInputTypeDefs } from './wrapping'
import type { GraphQLScalarTypeConfig } from 'graphql'
import type { AllInputTypes, GetGen2 } from '../typegenTypeHelpers'
import type { AllNexusArgsDefs, AllNexusInputTypeDefs } from './wrapping'
import { NexusTypes, withNexusSymbol } from './_types'
export type ArgsRecord = Record<string, AllNexusArgsDefs>

View File

@ -1,5 +1,5 @@
import { GraphQLNamedType } from 'graphql'
import { SourceTypingDef } from './_types'
import type { GraphQLNamedType } from 'graphql'
import type { SourceTypingDef } from './_types'
export interface TypeExtensionConfig {
asNexusMethod?: string

View File

@ -1,9 +1,16 @@
import { GraphQLFieldConfig, GraphQLFieldResolver, GraphQLInputFieldConfig } from 'graphql'
import type { GraphQLFieldConfig, GraphQLFieldResolver, GraphQLInputFieldConfig } from 'graphql'
import { messages } from '../messages'
import { AllInputTypes, FieldResolver, GetGen, GetGen3, HasGen3, NeedsResolver } from '../typegenTypeHelpers'
import { ArgsRecord } from './args'
import { AllNexusInputTypeDefs, AllNexusOutputTypeDefs, NexusWrapKind } from './wrapping'
import { BaseScalars } from './_types'
import type {
AllInputTypes,
FieldResolver,
GetGen,
GetGen3,
HasGen3,
NeedsResolver,
} from '../typegenTypeHelpers'
import type { ArgsRecord } from './args'
import type { AllNexusInputTypeDefs, AllNexusOutputTypeDefs, NexusWrapKind } from './wrapping'
import type { BaseScalars } from './_types'
export interface CommonFieldConfig {
//todo

View File

@ -1,6 +1,6 @@
import { assertValidName } from 'graphql'
import { GetGen } from '../typegenTypeHelpers'
import { InputDefinitionBlock } from './definitionBlocks'
import type { GetGen } from '../typegenTypeHelpers'
import type { InputDefinitionBlock } from './definitionBlocks'
import { NexusTypes, withNexusSymbol } from './_types'
export interface NexusExtendInputTypeConfig<TypeName extends string> {

View File

@ -1,7 +1,7 @@
import { assertValidName } from 'graphql'
import { AllOutputTypesPossible } from '../typegenTypeHelpers'
import { ObjectDefinitionBlock } from './objectType'
import { IsSubscriptionType, SubscriptionBuilder } from './subscriptionType'
import type { AllOutputTypesPossible } from '../typegenTypeHelpers'
import type { ObjectDefinitionBlock } from './objectType'
import type { IsSubscriptionType, SubscriptionBuilder } from './subscriptionType'
import { NexusTypes, withNexusSymbol } from './_types'
export interface NexusExtendTypeConfig<TypeName extends string> {

View File

@ -1,6 +1,6 @@
import { assertValidName, GraphQLInputObjectTypeConfig } from 'graphql'
import { arg, NexusArgDef, NexusAsArgConfig } from './args'
import { InputDefinitionBlock } from './definitionBlocks'
import type { InputDefinitionBlock } from './definitionBlocks'
import { NexusTypes, NonNullConfig, withNexusSymbol } from './_types'
export type NexusInputObjectTypeConfig<TypeName extends string> = {

View File

@ -1,6 +1,6 @@
import { assertValidName, GraphQLInterfaceTypeConfig } from 'graphql'
import { FieldResolver, GetGen, InterfaceFieldsFor, ModificationType } from '../typegenTypeHelpers'
import { ArgsRecord } from './args'
import type { FieldResolver, GetGen, InterfaceFieldsFor, ModificationType } from '../typegenTypeHelpers'
import type { ArgsRecord } from './args'
import { OutputDefinitionBlock, OutputDefinitionBuilder } from './definitionBlocks'
import { AbstractTypes, NexusTypes, NonNullConfig, SourceTypingDef, withNexusSymbol } from './_types'

View File

@ -1,4 +1,4 @@
import { FieldOutConfig, OutputDefinitionBlock } from '../core'
import type { FieldOutConfig, OutputDefinitionBlock } from '../core'
import { extendType, NexusExtendTypeDef } from './extendType'
export type MutationFieldConfig<FieldName extends string> =

View File

@ -67,7 +67,7 @@ withNexusSymbol(NexusNonNullDef, NexusTypes.NonNull)
*/
export function nonNull<TypeName extends NexusNonNullableTypes>(type: TypeName) {
if (isNexusNonNullTypeDef(type) || isNonNullType(type)) {
/*
/*
Ran into an issue around the generated return type for `nonNull()`,
which produces:

View File

@ -1,7 +1,7 @@
import { assertValidName, GraphQLObjectType } from 'graphql'
import { InterfaceFieldsFor } from '../typegenTypeHelpers'
import type { InterfaceFieldsFor } from '../typegenTypeHelpers'
import { OutputDefinitionBlock, OutputDefinitionBuilder } from './definitionBlocks'
import { FieldModification, FieldModificationDef, Implemented } from './interfaceType'
import type { FieldModification, FieldModificationDef, Implemented } from './interfaceType'
import { AbstractTypes, NexusTypes, NonNullConfig, SourceTypingDef, withNexusSymbol } from './_types'
export interface ObjectDefinitionBuilder extends OutputDefinitionBuilder {

View File

@ -1,4 +1,4 @@
import { FieldOutConfig, OutputDefinitionBlock } from '../core'
import type { FieldOutConfig, OutputDefinitionBlock } from '../core'
import { extendType, NexusExtendTypeDef } from './extendType'
export type QueryFieldConfig<FieldName extends string> =

View File

@ -1,5 +1,5 @@
import { extendType, NexusExtendTypeDef } from './extendType'
import { SubscriptionBuilder, SubscriptionTypeConfig } from './subscriptionType'
import type { SubscriptionBuilder, SubscriptionTypeConfig } from './subscriptionType'
export type SubscriptionFieldConfig<FieldName extends string, Event> =
| SubscriptionTypeConfig<FieldName, Event>

View File

@ -1,9 +1,9 @@
import { GraphQLResolveInfo } from 'graphql'
import { ArgsValue, GetGen, MaybePromise, MaybePromiseDeep, ResultValue } from '../typegenTypeHelpers'
import { IsEqual } from '../typeHelpersInternal'
import { CommonOutputFieldConfig } from './definitionBlocks'
import type { GraphQLResolveInfo } from 'graphql'
import type { ArgsValue, GetGen, MaybePromise, MaybePromiseDeep, ResultValue } from '../typegenTypeHelpers'
import type { IsEqual } from '../typeHelpersInternal'
import type { CommonOutputFieldConfig } from './definitionBlocks'
import { objectType } from './objectType'
import { AllNexusOutputTypeDefs } from './wrapping'
import type { AllNexusOutputTypeDefs } from './wrapping'
export type IsSubscriptionType<T> = IsEqual<T, 'Subscription'>

View File

@ -1,6 +1,6 @@
import { assertValidName, GraphQLUnionTypeConfig } from 'graphql'
import { GetGen } from '../typegenTypeHelpers'
import { NexusObjectTypeDef } from './objectType'
import type { GetGen } from '../typegenTypeHelpers'
import type { NexusObjectTypeDef } from './objectType'
import { AbstractTypes, NexusTypes, SourceTypingDef, withNexusSymbol } from './_types'
export interface UnionDefinitionBuilder {

View File

@ -8,23 +8,23 @@ import {
isListType,
isNonNullType,
} from 'graphql'
import { DynamicInputMethodDef, DynamicOutputMethodDef } from '../dynamicMethod'
import { DynamicOutputPropertyDef } from '../dynamicProperty'
import { NexusPlugin } from '../plugin'
import { AllInputTypes, GetGen } from '../typegenTypeHelpers'
import type { DynamicInputMethodDef, DynamicOutputMethodDef } from '../dynamicMethod'
import type { DynamicOutputPropertyDef } from '../dynamicProperty'
import type { NexusPlugin } from '../plugin'
import type { AllInputTypes, GetGen } from '../typegenTypeHelpers'
import { PrintedGenTyping, PrintedGenTypingImport, Unreachable } from '../utils'
import { NexusArgDef, arg } from './args'
import { NexusEnumTypeDef } from './enumType'
import { NexusExtendInputTypeDef } from './extendInputType'
import { NexusExtendTypeDef } from './extendType'
import { NexusInputObjectTypeDef } from './inputObjectType'
import { NexusInterfaceTypeDef } from './interfaceType'
import type { NexusEnumTypeDef } from './enumType'
import type { NexusExtendInputTypeDef } from './extendInputType'
import type { NexusExtendTypeDef } from './extendType'
import type { NexusInputObjectTypeDef } from './inputObjectType'
import type { NexusInterfaceTypeDef } from './interfaceType'
import { list, NexusListDef } from './list'
import { NexusNonNullDef, nonNull } from './nonNull'
import { NexusNullDef, nullable } from './nullable'
import { NexusObjectTypeDef } from './objectType'
import { NexusScalarTypeDef } from './scalarType'
import { NexusUnionTypeDef } from './unionType'
import type { NexusObjectTypeDef } from './objectType'
import type { NexusScalarTypeDef } from './scalarType'
import type { NexusUnionTypeDef } from './unionType'
import { NexusTypes, NexusWrappedSymbol } from './_types'
export type AllNexusNamedInputTypeDefs<T extends string = any> =

View File

@ -1,7 +1,7 @@
import { PluginBuilderLens } from './builder'
import { InputDefinitionBlock, OutputDefinitionBlock } from './definitions/definitionBlocks'
import type { PluginBuilderLens } from './builder'
import type { InputDefinitionBlock, OutputDefinitionBlock } from './definitions/definitionBlocks'
import { NexusTypes, withNexusSymbol } from './definitions/_types'
import { NexusWrapKind } from './definitions/wrapping'
import type { NexusWrapKind } from './definitions/wrapping'
export type OutputFactoryConfig<T> = {
/** The name of the type this field is being declared on */

View File

@ -1,7 +1,7 @@
import { SchemaBuilder } from './builder'
import { OutputDefinitionBlock } from './definitions/definitionBlocks'
import type { SchemaBuilder } from './builder'
import type { OutputDefinitionBlock } from './definitions/definitionBlocks'
import { NexusTypes, withNexusSymbol } from './definitions/_types'
import { BaseExtensionConfig } from './dynamicMethod'
import type { BaseExtensionConfig } from './dynamicMethod'
export type OutputPropertyFactoryConfig<T> = {
stage: 'walk' | 'build'

View File

@ -1,10 +1,10 @@
import { defaultFieldResolver, GraphQLNamedType } from 'graphql'
import { DynamicFieldDefs, SchemaConfig } from './builder'
import { SourceTypingDef, SourceTypings } from './definitions/_types'
import { NexusOutputFieldConfig } from './definitions/definitionBlocks'
import { NexusInputObjectTypeConfig } from './definitions/inputObjectType'
import { NexusInterfaceTypeConfig } from './definitions/interfaceType'
import { NexusObjectTypeConfig } from './definitions/objectType'
import type { DynamicFieldDefs, SchemaConfig } from './builder'
import type { SourceTypingDef, SourceTypings } from './definitions/_types'
import type { NexusOutputFieldConfig } from './definitions/definitionBlocks'
import type { NexusInputObjectTypeConfig } from './definitions/inputObjectType'
import type { NexusInterfaceTypeConfig } from './definitions/interfaceType'
import type { NexusObjectTypeConfig } from './definitions/objectType'
export type NexusGraphQLNamedType = GraphQLNamedType & {
extensions?: {

View File

@ -1,5 +1,5 @@
import { GraphQLFieldResolver, GraphQLInterfaceType, GraphQLResolveInfo, GraphQLSchema } from 'graphql'
import { PluginBuilderLens, SchemaConfig } from './builder'
import type { GraphQLFieldResolver, GraphQLInterfaceType, GraphQLResolveInfo, GraphQLSchema } from 'graphql'
import type { PluginBuilderLens, SchemaConfig } from './builder'
import {
Maybe,
NexusGraphQLFieldConfig,
@ -9,13 +9,17 @@ import {
Omit,
withNexusSymbol,
} from './definitions/_types'
import { InputDefinitionBlock, NexusOutputFieldDef, NexusInputFieldDef } from './definitions/definitionBlocks'
import { NexusInputObjectTypeConfig } from './definitions/inputObjectType'
import { NexusObjectTypeConfig, ObjectDefinitionBlock } from './definitions/objectType'
import { NexusSchemaExtension } from './extensions'
import type {
InputDefinitionBlock,
NexusOutputFieldDef,
NexusInputFieldDef,
} from './definitions/definitionBlocks'
import type { NexusInputObjectTypeConfig } from './definitions/inputObjectType'
import type { NexusObjectTypeConfig, ObjectDefinitionBlock } from './definitions/objectType'
import type { NexusSchemaExtension } from './extensions'
import { isPromiseLike, PrintedGenTyping, PrintedGenTypingImport, venn } from './utils'
import { NexusFinalArgConfig } from './definitions/args'
import { UnwrapPromise } from './typeHelpersInternal'
import type { NexusFinalArgConfig } from './definitions/args'
import type { UnwrapPromise } from './typeHelpersInternal'
export { PluginBuilderLens }

View File

@ -1,6 +1,6 @@
import { defaultFieldResolver, GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql'
import { ArgsRecord, intArg, stringArg } from '../definitions/args'
import { CommonFieldConfig, FieldOutConfig } from '../definitions/definitionBlocks'
import type { CommonFieldConfig, FieldOutConfig } from '../definitions/definitionBlocks'
import { NexusNonNullDef, nonNull } from '../definitions/nonNull'
import { NexusNullDef, nullable } from '../definitions/nullable'
import { ObjectDefinitionBlock, objectType } from '../definitions/objectType'
@ -9,10 +9,10 @@ import {
AllNexusOutputTypeDefs,
applyNexusWrapping,
} from '../definitions/wrapping'
import { NonNullConfig } from '../definitions/_types'
import type { NonNullConfig } from '../definitions/_types'
import { dynamicOutputMethod } from '../dynamicMethod'
import { completeValue, plugin } from '../plugin'
import {
import type {
ArgsValue,
FieldTypeName,
GetGen,
@ -21,7 +21,7 @@ import {
ResultValue,
SourceValue,
} from '../typegenTypeHelpers'
import { MaybePromiseLike } from '../typeHelpersInternal'
import type { MaybePromiseLike } from '../typeHelpersInternal'
import { eachObj, getOwnPackage, isPromiseLike, mapObj, pathToArray, printedGenTypingImport } from '../utils'
export interface ConnectionPluginConfig {

View File

@ -1,5 +1,5 @@
import { NexusFinalArgConfig } from '../definitions/args'
import { NexusInputFieldDef, NexusOutputFieldDef } from '../definitions/definitionBlocks'
import type { NexusFinalArgConfig } from '../definitions/args'
import type { NexusInputFieldDef, NexusOutputFieldDef } from '../definitions/definitionBlocks'
import { list } from '../definitions/list'
import { nonNull } from '../definitions/nonNull'
import { nullable } from '../definitions/nullable'

View File

@ -1,6 +1,6 @@
import { GraphQLResolveInfo } from 'graphql'
import type { GraphQLResolveInfo } from 'graphql'
import { plugin } from '../plugin'
import { ArgsValue, GetGen, MaybePromise, SourceValue } from '../typegenTypeHelpers'
import type { ArgsValue, GetGen, MaybePromise, SourceValue } from '../typegenTypeHelpers'
import { printedGenTyping, printedGenTypingImport } from '../utils'
const FieldauthorizeResolverImport = printedGenTypingImport({

View File

@ -12,10 +12,10 @@ import {
isWrappingType,
} from 'graphql'
import { forEach } from 'iterall'
import { GraphQLPossibleOutputs } from '../definitions/_types'
import { NexusGraphQLNamedType } from '../extensions'
import type { GraphQLPossibleOutputs } from '../definitions/_types'
import type { NexusGraphQLNamedType } from '../extensions'
import { CreateFieldResolverInfo, plugin } from '../plugin'
import { AllOutputTypes, GetGen, GetGen2 } from '../typegenTypeHelpers'
import type { AllOutputTypes, GetGen, GetGen2 } from '../typegenTypeHelpers'
import { isPromiseLike, printedGenTyping } from '../utils'
export interface NullabilityPluginFallbackFn {

View File

@ -1,5 +1,5 @@
import { GraphQLField } from 'graphql'
import { ArgsValue, GetGen, SourceValue } from '../core'
import type { GraphQLField } from 'graphql'
import type { ArgsValue, GetGen, SourceValue } from '../core'
import { plugin } from '../plugin'
import { printedGenTyping, printedGenTypingImport } from '../utils'

View File

@ -1,5 +1,5 @@
import { GraphQLResolveInfo } from 'graphql'
import {
import type { GraphQLResolveInfo } from 'graphql'
import type {
AbstractTypeResolver,
GetGen,
GetGen2,
@ -7,7 +7,7 @@ import {
MaybePromise,
SourceValue,
} from './typegenTypeHelpers'
import { ConditionalKeys, ConditionalPick, ValueOf } from './typeHelpersInternal'
import type { ConditionalKeys, ConditionalPick, ValueOf } from './typeHelpersInternal'
/**
* Returns a union of all the type names of the members of an abstract type

View File

@ -1,7 +1,7 @@
import { GraphQLNamedType, GraphQLSchema, isOutputType } from 'graphql'
import * as path from 'path'
import { TypegenInfo } from './builder'
import { TypingImport } from './definitions/_types'
import type { TypegenInfo } from './builder'
import type { TypingImport } from './definitions/_types'
import { TYPEGEN_HEADER } from './lang'
import { getOwnPackage, log, objValues, relativePathTo, typeScriptFileExtension } from './utils'
@ -261,7 +261,7 @@ export function typegenAutoConfig(options: SourceTypesConfigOptions, contextType
.forEach((alias) => {
const [importPath, glob] = importsMap[alias]
const safeImportPath = importPath.replace(/\\+/g, '/')
imports.push(`import ${glob ? '* as ' : ''}${alias} from "${safeImportPath}"`)
imports.push(`import type ${glob ? '* as ' : ''}${alias} from "${safeImportPath}"`)
})
const typegenInfo = {

View File

@ -1,7 +1,7 @@
import { GraphQLSchema, lexicographicSortSchema, printSchema } from 'graphql'
import * as path from 'path'
import { BuilderConfigInput, TypegenInfo } from './builder'
import { NexusGraphQLSchema } from './definitions/_types'
import type { BuilderConfigInput, TypegenInfo } from './builder'
import type { NexusGraphQLSchema } from './definitions/_types'
import { SDL_HEADER, TYPEGEN_HEADER } from './lang'
import { typegenAutoConfig } from './typegenAutoConfig'
import { TypegenFormatFn, typegenFormatPrettier } from './typegenFormatPrettier'

View File

@ -21,10 +21,10 @@ import {
isSpecifiedScalarType,
isUnionType,
} from 'graphql'
import { TypegenInfo } from './builder'
import type { TypegenInfo } from './builder'
import { isNexusPrintedGenTyping, isNexusPrintedGenTypingImport } from './definitions/wrapping'
import { NexusGraphQLSchema } from './definitions/_types'
import { StringLike } from './plugin'
import type { NexusGraphQLSchema } from './definitions/_types'
import type { StringLike } from './plugin'
import {
eachObj,
getOwnPackage,
@ -198,7 +198,7 @@ export class TypegenPrinter {
}
})
eachObj(importMap, (val, key) => {
imports.push(`import { ${Array.from(val).join(', ')} } from ${JSON.stringify(key)}`)
imports.push(`import type { ${Array.from(val).join(', ')} } from ${JSON.stringify(key)}`)
})
eachObj(this.printImports, (val, key) => {
const { default: def, ...rest } = val
@ -213,7 +213,7 @@ export class TypegenPrinter {
if (bindings.length) {
idents.push(`{ ${bindings.join(', ')} }`)
}
imports.push(`import ${idents.join(', ')} from ${JSON.stringify(key)}`)
imports.push(`import type ${idents.join(', ')} from ${JSON.stringify(key)}`)
})
return imports.join('\n')
}

View File

@ -1,5 +1,5 @@
import { expectAssignable } from 'tsd'
import { MaybePromiseDeep } from './typegenTypeHelpers'
import type { MaybePromiseDeep } from './typegenTypeHelpers'
/** MaybePromiseDeep */

View File

@ -1,6 +1,6 @@
import { GraphQLAbstractType, GraphQLResolveInfo } from 'graphql'
import { NexusInterfaceTypeDef } from './definitions/interfaceType'
import { NexusObjectTypeDef } from './definitions/objectType'
import type { GraphQLAbstractType, GraphQLResolveInfo } from 'graphql'
import type { NexusInterfaceTypeDef } from './definitions/interfaceType'
import type { NexusObjectTypeDef } from './definitions/objectType'
declare global {
interface NexusGen {}

View File

@ -1,6 +1,6 @@
import * as path from 'path'
import { BuilderConfigInput } from './builder'
import { TypegenMetadataConfig } from './typegenMetadata'
import type { BuilderConfigInput } from './builder'
import type { TypegenMetadataConfig } from './typegenMetadata'
import { assertAbsolutePath, getOwnPackage, isProductionStage } from './utils'
/** Normalizes the builder config into the config we need for typegen */

View File

@ -19,7 +19,7 @@ exports[`sourceTypings can import enum via sourceType 1`] = `
*/
import { TestEnum } from \\"./tests/backingTypes.spec\\"
import type { TestEnum } from \\"./tests/backingTypes.spec\\"

View File

@ -149,8 +149,8 @@ exports[`typegenPrinter should print the full output 1`] = `
*/
import { TestContext } from \\"./tests/__helpers/index\\"
import { core } from \\"nexus\\"
import type { TestContext } from \\"./tests/__helpers/index\\"
import type { core } from \\"nexus\\"

View File

@ -1,7 +1,7 @@
import * as fs from 'fs-jetpack'
import * as Path from 'path'
import * as tsm from 'ts-morph'
import * as ts from 'typescript'
import type * as ts from 'typescript'
;(global as any).TS_FORMAT_PROJECT_ROOT = 'src/'
export function typeCheck(

View File

@ -1,6 +1,6 @@
/// <reference types="jest" />
import { GraphQLEnumType, GraphQLObjectType, printType } from 'graphql'
import { TypeMap } from 'graphql/type/schema'
import type { TypeMap } from 'graphql/type/schema'
import { enumType, extendInputType, extendType, idArg, inputObjectType, makeSchema, objectType } from '../src'
import { list } from '../src/definitions/list'
import { nonNull } from '../src/definitions/nonNull'

View File

@ -1,6 +1,6 @@
/** This file was generated by Nexus Schema Do not make changes to this file directly */
import { core } from '../../../../src'
import type { core } from '../../../../src'
declare global {
interface NexusGen extends NexusGenTypes {}

View File

@ -1,6 +1,6 @@
/** This file was generated by Nexus Schema Do not make changes to this file directly */
import { core } from '../../../../src'
import type { core } from '../../../../src'
declare global {
interface NexusGen extends NexusGenTypes {}

View File

@ -1,6 +1,6 @@
/** This file was generated by Nexus Schema Do not make changes to this file directly */
import { core, connectionPluginCore } from '../../../src'
import type { core, connectionPluginCore } from '../../../src'
declare global {
interface NexusGenCustomInputMethods<TypeName extends string> {
/** No-Op scalar for testing purposes only */
@ -96,10 +96,12 @@ export interface NexusGenObjects {
// root type
edges?: Array<NexusGenRootTypes['PostEdge'] | null> | null // [PostEdge]
pageInfo: NexusGenRootTypes['PageInfo'] // PageInfo!
totalCount: number // Int!
}
PostEdge: {
// root type
cursor: string // String!
delta?: string | null // String
node?: NexusGenRootTypes['Post'] | null // Post
}
Query: {}

View File

@ -110,7 +110,7 @@ describe('makeSchema', () => {
},
path.normalize(`/dev/null/file.ts`)
)
expect(tsTypes).toContain(`import { GraphQLInputFieldConfigMap } from "graphql"`)
expect(tsTypes).toContain(`import type { GraphQLInputFieldConfigMap } from "graphql"`)
expect(tsTypes).toContain(`context: GraphQLInputFieldConfigMap`)
})
@ -147,8 +147,8 @@ describe('makeSchema', () => {
path.join(__dirname, 'nexus.ts')
)
expect(tsTypes).toContain(`import * as thisFile from "./makeSchema.spec"`)
expect(tsTypes).toContain(`import { Context } from "./makeSchema.spec"`)
expect(tsTypes).toContain(`import type * as thisFile from "./makeSchema.spec"`)
expect(tsTypes).toContain(`import type { Context } from "./makeSchema.spec"`)
})
})
})

View File

@ -1,4 +1,4 @@
import { GraphQLArgument, GraphQLInputObjectType, GraphQLInputType, GraphQLOutputType } from 'graphql'
import type { GraphQLArgument, GraphQLInputObjectType, GraphQLInputType, GraphQLOutputType } from 'graphql'
import { list, makeSchema, nonNull, nullable } from '../src'
import { arg, inputObjectType, objectType, queryType, stringArg } from '../src/core'

View File

@ -49,7 +49,7 @@ exports[`fieldAuthorizePlugin printing the authorize schema: Full Type Output 1`
*/
import { FieldAuthorizeResolver } from \\"nexus/dist/plugins/fieldAuthorizePlugin\\"
import type { FieldAuthorizeResolver } from \\"nexus/dist/plugins/fieldAuthorizePlugin\\"

View File

@ -7,7 +7,7 @@ exports[`queryComplexityPlugin printing the query complexity schema: Full Type O
*/
import { QueryComplexity } from \\"nexus/dist/plugins/queryComplexityPlugin\\"
import type { QueryComplexity } from \\"nexus/dist/plugins/queryComplexityPlugin\\"

View File

@ -12,7 +12,7 @@ import {
import { connectionFromArray } from 'graphql-relay'
import { arg, connectionPlugin, makeSchema, nonNull, objectType } from '../../src'
import { generateSchema, SchemaConfig, scalarType, queryField } from '../../src/core'
import { ConnectionFieldConfig, ConnectionPluginConfig } from '../../src/plugins/connectionPlugin'
import type { ConnectionFieldConfig, ConnectionPluginConfig } from '../../src/plugins/connectionPlugin'
const userNodes: { id: string; name: string }[] = []
for (let i = 0; i < 10; i++) {

View File

@ -1,4 +1,4 @@
import { GraphQLInputObjectType, GraphQLSchema } from 'graphql'
import type { GraphQLInputObjectType, GraphQLSchema } from 'graphql'
import { makeSchema, queryType } from '../../src'
import { arg, inputObjectType, declarativeWrappingPlugin, SchemaConfig } from '../../src/core'

View File

@ -1,4 +1,4 @@
import { GraphQLObjectType } from 'graphql'
import type { GraphQLObjectType } from 'graphql'
import path from 'path'
import { makeSchema, objectType, queryComplexityPlugin, queryField } from '../../src'
import { generateSchema, declarativeWrappingPlugin } from '../../src/core'

View File

@ -88,7 +88,7 @@ describe('scalarType', () => {
})
const generator = new TypegenMetadata(resolveTypegenConfig(schema.finalConfig))
const typegen = await generator.generateTypesFile(schema.schema, 'foo.ts')
expect(typegen).toMatch(/import { GraphQLScalar } from \"graphql\"/)
expect(typegen).toMatch(/import type { GraphQLScalar } from \"graphql\"/)
})
it('can override the backing type for known scalars', async () => {

View File

@ -1,6 +1,6 @@
/** This file was generated by Nexus Schema Do not make changes to this file directly */
import { core } from '../../src'
import type { core } from '../../src'
declare global {
interface NexusGen extends NexusGenTypes {}

View File

@ -1,7 +1,7 @@
import { executeSync, parse } from 'graphql'
import { connectionPlugin, makeSchema, objectType } from '../../src'
import { SchemaConfig } from '../../src/core'
import { ConnectionFieldConfig, ConnectionPluginConfig } from '../../src/plugins/connectionPlugin'
import type { SchemaConfig } from '../../src/core'
import type { ConnectionFieldConfig, ConnectionPluginConfig } from '../../src/plugins/connectionPlugin'
const userNodes: { id: string; name: string }[] = []
for (let i = 0; i < 10; i++) {

View File

@ -4,7 +4,8 @@
"module": "CommonJS",
"declaration": true,
// "declarationMap": true,
"sourceMap": true
"sourceMap": true,
"noEmit": false
},
"exclude": [
"./**/*.spec.types.ts",

View File

@ -9,7 +9,9 @@
"strict": true,
"noUnusedLocals": true,
"importHelpers": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"noEmit": true,
"importsNotUsedAsValues": "error"
},
"exclude": [
"./examples",