From fea7981b566cf4a7194c1196a0a4833072d910bd Mon Sep 17 00:00:00 2001 From: Quramy Date: Mon, 18 Mar 2024 19:11:29 +0900 Subject: [PATCH] chore: Modify type imports --- src/analyzer/analyzer-factory.test.ts | 2 +- src/analyzer/analyzer-factory.ts | 4 ++-- src/analyzer/analyzer.ts | 6 +++--- src/analyzer/extractor.ts | 2 +- src/analyzer/markdown-reporter.ts | 4 ++-- src/analyzer/type-generator.ts | 16 +++++++++++----- src/analyzer/validator.ts | 6 +++--- src/cli/commands/extract.ts | 4 ++-- src/cli/commands/report.ts | 6 +++--- src/cli/commands/typegen.ts | 4 ++-- src/cli/commands/validate.ts | 4 ++-- src/errors/error-reporter.ts | 4 ++-- src/gql-ast-util/fragment-registry.ts | 2 +- src/gql-ast-util/utility-functions.ts | 2 +- .../get-completion-at-position.ts | 4 ++-- .../get-quick-info-at-position.ts | 2 +- .../get-semantic-diagnostics.ts | 2 +- .../graphql-language-service-adapter.ts | 18 ++++++++---------- src/graphql-language-service-adapter/types.ts | 8 ++++---- .../language-service-proxy-builder.ts | 2 +- .../plugin-module-factory.ts | 2 +- src/register-hooks/register-typescript.ts | 2 +- src/schema-manager/extension-manager.ts | 8 ++++---- src/schema-manager/file-schema-manager.ts | 6 +++--- src/schema-manager/http-schema-manager.ts | 2 +- .../request-introspection-query.ts | 8 ++++---- src/schema-manager/schema-manager-factory.ts | 2 +- src/schema-manager/schema-manager-host.ts | 8 ++++---- src/schema-manager/schema-manager.ts | 4 ++-- .../scripted-http-schema-manager.ts | 4 ++-- src/transformer/transformer-host.ts | 8 ++++---- src/transformer/transformer.ts | 2 +- src/ts-ast-util/output-source.ts | 7 +++---- src/ts-ast-util/script-source-helper.ts | 2 +- .../template-expression-resolver.ts | 2 +- src/ts-ast-util/types.ts | 2 +- src/typegen-addons/typed-query-document.ts | 2 +- src/typegen/type-gen-visitor.ts | 18 +++++++++--------- src/webpack/plugin.ts | 4 ++-- tools/add-toc.ts | 4 ++-- 40 files changed, 101 insertions(+), 98 deletions(-) diff --git a/src/analyzer/analyzer-factory.test.ts b/src/analyzer/analyzer-factory.test.ts index 539bc09b9..5aee31175 100644 --- a/src/analyzer/analyzer-factory.test.ts +++ b/src/analyzer/analyzer-factory.test.ts @@ -1,4 +1,4 @@ -import path from 'path'; +import path from 'node:path'; import { AnalyzerFactory } from './analyzer-factory'; import { Analyzer } from './analyzer'; diff --git a/src/analyzer/analyzer-factory.ts b/src/analyzer/analyzer-factory.ts index 3e861f58d..8a7cfa5cf 100644 --- a/src/analyzer/analyzer-factory.ts +++ b/src/analyzer/analyzer-factory.ts @@ -1,7 +1,7 @@ -import path from 'path'; +import path from 'node:path'; import ts from 'typescript'; import { Analyzer } from './analyzer'; -import { TsGraphQLPluginConfigOptions } from '../types'; +import type { TsGraphQLPluginConfigOptions } from '../types'; import { ScriptHost } from '../ts-ast-util'; import { SchemaManagerFactory, createSchemaManagerHostFromTSGqlPluginConfig } from '../schema-manager'; import { ErrorWithoutLocation } from '../errors'; diff --git a/src/analyzer/analyzer.ts b/src/analyzer/analyzer.ts index e3c811b84..f7f8fd9fb 100644 --- a/src/analyzer/analyzer.ts +++ b/src/analyzer/analyzer.ts @@ -1,6 +1,6 @@ +import path from 'node:path'; import ts from 'typescript'; -import path from 'path'; -import { ScriptSourceHelper } from '../ts-ast-util/types'; +import type { ScriptSourceHelper } from '../ts-ast-util/types'; import { Extractor } from './extractor'; import { createScriptSourceHelper, @@ -15,7 +15,7 @@ import { SchemaManager, SchemaBuildErrorInfo } from '../schema-manager/schema-ma import { TsGqlError, ErrorWithLocation, ErrorWithoutLocation } from '../errors'; import { location2pos } from '../string-util'; import { validate } from './validator'; -import { ManifestOutput, TsGraphQLPluginConfig } from './types'; +import type { ManifestOutput, TsGraphQLPluginConfig } from './types'; import { MarkdownReporter } from './markdown-reporter'; import { TypeGenerator } from './type-generator'; import { createFileNameFilter } from '../ts-ast-util/file-name-filter'; diff --git a/src/analyzer/extractor.ts b/src/analyzer/extractor.ts index fa3288827..c92bd0035 100644 --- a/src/analyzer/extractor.ts +++ b/src/analyzer/extractor.ts @@ -17,7 +17,7 @@ import { ResolvedTemplateInfo, StrictTagCondition, } from '../ts-ast-util'; -import { ManifestOutput, ManifestDocumentEntry, OperationType } from './types'; +import type { ManifestOutput, ManifestDocumentEntry, OperationType } from './types'; import { ErrorWithLocation, ERROR_CODES } from '../errors'; import { detectDuplicatedFragments, diff --git a/src/analyzer/markdown-reporter.ts b/src/analyzer/markdown-reporter.ts index 713553eba..2ed00b852 100644 --- a/src/analyzer/markdown-reporter.ts +++ b/src/analyzer/markdown-reporter.ts @@ -1,5 +1,5 @@ -import path from 'path'; -import { ManifestOutput, ManifestDocumentEntry } from './types'; +import path from 'node:path'; +import type { ManifestOutput, ManifestDocumentEntry } from './types'; export type ToMarkdownContentOptions = { baseDir: string; diff --git a/src/analyzer/type-generator.ts b/src/analyzer/type-generator.ts index 78fed41bf..9b41bf6a2 100644 --- a/src/analyzer/type-generator.ts +++ b/src/analyzer/type-generator.ts @@ -1,12 +1,18 @@ -import path from 'path'; +import path from 'node:path'; import ts from 'typescript'; -import { GraphQLSchema } from 'graphql'; +import type { GraphQLSchema } from 'graphql'; import { TsGqlError, ErrorWithLocation } from '../errors'; -import { mergeAddons, TypeGenVisitor, TypeGenError, TypeGenAddonFactory, TypeGenVisitorAddonContext } from '../typegen'; +import { + mergeAddons, + TypeGenVisitor, + TypeGenError, + type TypeGenAddonFactory, + type TypeGenVisitorAddonContext, +} from '../typegen'; import { dasherize } from '../string-util'; -import { OutputSource, createOutputSource, type StrictTagCondition } from '../ts-ast-util'; -import { Extractor, ExtractSucceededResult } from './extractor'; +import { createOutputSource, type OutputSource, type StrictTagCondition } from '../ts-ast-util'; +import type { Extractor, ExtractSucceededResult } from './extractor'; export type TypeGeneratorOptions = { prjRootPath: string; diff --git a/src/analyzer/validator.ts b/src/analyzer/validator.ts index 224b4ed77..5ec63a6e1 100644 --- a/src/analyzer/validator.ts +++ b/src/analyzer/validator.ts @@ -1,9 +1,9 @@ -import { GraphQLSchema } from 'graphql'; +import type { GraphQLSchema } from 'graphql'; import { getDiagnostics, getFragmentDependenciesForAST } from 'graphql-language-service'; import { ErrorWithLocation, ERROR_CODES } from '../errors'; -import { ComputePosition } from '../ts-ast-util'; +import type { ComputePosition } from '../ts-ast-util'; import { getFragmentsInDocument, getFragmentNamesInDocument, cloneFragmentMap } from '../gql-ast-util'; -import { ExtractResult } from './extractor'; +import type { ExtractResult } from './extractor'; import { OutOfRangeError } from '../string-util'; function calcEndPositionSafely( diff --git a/src/cli/commands/extract.ts b/src/cli/commands/extract.ts index b89df6770..6aafcdc54 100644 --- a/src/cli/commands/extract.ts +++ b/src/cli/commands/extract.ts @@ -1,4 +1,4 @@ -import { CommandOptions } from '../parser'; +import type { CommandOptions, CommandCliSetting } from '../parser'; import { ConsoleLogger } from '../logger'; export const cliDefinition = { @@ -22,7 +22,7 @@ export const cliDefinition = { type: 'boolean', }, }, -} as const; +} as const satisfies CommandCliSetting; export async function extractCommand({ options }: CommandOptions) { const ts = require('typescript') as typeof import('typescript'); diff --git a/src/cli/commands/report.ts b/src/cli/commands/report.ts index c9a249942..d9414abaf 100644 --- a/src/cli/commands/report.ts +++ b/src/cli/commands/report.ts @@ -1,5 +1,5 @@ -import path from 'path'; -import { CommandOptions } from '../parser'; +import path from 'node:path'; +import type { CommandOptions, CommandCliSetting } from '../parser'; import { ConsoleLogger } from '../logger'; export const cliDefinition = { @@ -32,7 +32,7 @@ export const cliDefinition = { type: 'boolean', }, }, -} as const; +} as const satisfies CommandCliSetting; export async function reportCommand({ options }: CommandOptions) { const ts = require('typescript') as typeof import('typescript'); diff --git a/src/cli/commands/typegen.ts b/src/cli/commands/typegen.ts index 0a092ca4b..35297a78e 100644 --- a/src/cli/commands/typegen.ts +++ b/src/cli/commands/typegen.ts @@ -1,4 +1,4 @@ -import { CommandOptions } from '../parser'; +import type { CommandOptions, CommandCliSetting } from '../parser'; import { ConsoleLogger } from '../logger'; export const cliDefinition = { @@ -16,7 +16,7 @@ export const cliDefinition = { type: 'boolean', }, }, -} as const; +} as const satisfies CommandCliSetting; export async function typegenCommand({ options }: CommandOptions) { const ts = require('typescript') as typeof import('typescript'); diff --git a/src/cli/commands/validate.ts b/src/cli/commands/validate.ts index 71016b14d..837b0f10f 100644 --- a/src/cli/commands/validate.ts +++ b/src/cli/commands/validate.ts @@ -1,4 +1,4 @@ -import { CommandOptions } from '../parser'; +import type { CommandOptions, CommandCliSetting } from '../parser'; import { ConsoleLogger } from '../logger'; export const cliDefinition = { @@ -20,7 +20,7 @@ export const cliDefinition = { type: 'boolean', }, }, -} as const; +} as const satisfies CommandCliSetting; export async function validateCommand({ options }: CommandOptions) { const { AnalyzerFactory } = require('../../analyzer') as typeof import('../../analyzer'); diff --git a/src/errors/error-reporter.ts b/src/errors/error-reporter.ts index ceec0ca5c..173120939 100644 --- a/src/errors/error-reporter.ts +++ b/src/errors/error-reporter.ts @@ -1,6 +1,6 @@ -import path from 'path'; -import { TsGqlError, ErrorWithLocation, ErrorWithoutLocation } from '.'; +import path from 'node:path'; import { pos2location, pad, color } from '../string-util'; +import { type TsGqlError, ErrorWithLocation, ErrorWithoutLocation } from '.'; const lineMark = (line: number, width: number) => { const strLine = line + 1 + ''; diff --git a/src/gql-ast-util/fragment-registry.ts b/src/gql-ast-util/fragment-registry.ts index a9b4940a6..f83985043 100644 --- a/src/gql-ast-util/fragment-registry.ts +++ b/src/gql-ast-util/fragment-registry.ts @@ -1,4 +1,4 @@ -import { parse, type DocumentNode, FragmentDefinitionNode, visit } from 'graphql'; +import { parse, visit, type DocumentNode, type FragmentDefinitionNode } from 'graphql'; import { getFragmentDependenciesForAST } from 'graphql-language-service'; import { LRUCache } from '../cache'; import { getFragmentsInDocument, getFragmentNamesInDocument } from './utility-functions'; diff --git a/src/gql-ast-util/utility-functions.ts b/src/gql-ast-util/utility-functions.ts index 052278c22..1333b28a6 100644 --- a/src/gql-ast-util/utility-functions.ts +++ b/src/gql-ast-util/utility-functions.ts @@ -1,4 +1,4 @@ -import { DocumentNode, FragmentDefinitionNode } from 'graphql'; +import type { DocumentNode, FragmentDefinitionNode } from 'graphql'; export function getFragmentsInDocument(...documentNodes: (DocumentNode | undefined)[]) { const fragmentDefs = new Map(); diff --git a/src/graphql-language-service-adapter/get-completion-at-position.ts b/src/graphql-language-service-adapter/get-completion-at-position.ts index 2c8aef521..7eb419fc3 100644 --- a/src/graphql-language-service-adapter/get-completion-at-position.ts +++ b/src/graphql-language-service-adapter/get-completion-at-position.ts @@ -1,6 +1,6 @@ -import ts from 'typescript'; +import type ts from 'typescript'; import { getAutocompleteSuggestions, type CompletionItem } from 'graphql-language-service'; -import { AnalysisContext, GetCompletionAtPosition } from './types'; +import type { AnalysisContext, GetCompletionAtPosition } from './types'; import { SimplePosition } from './simple-position'; function translateCompletionItems(items: CompletionItem[]): ts.CompletionInfo { diff --git a/src/graphql-language-service-adapter/get-quick-info-at-position.ts b/src/graphql-language-service-adapter/get-quick-info-at-position.ts index 7fb0bc297..3e470d927 100644 --- a/src/graphql-language-service-adapter/get-quick-info-at-position.ts +++ b/src/graphql-language-service-adapter/get-quick-info-at-position.ts @@ -1,6 +1,6 @@ import ts from 'typescript'; import { getHoverInformation } from 'graphql-language-service'; -import { AnalysisContext, GetQuickInfoAtPosition } from './types'; +import type { AnalysisContext, GetQuickInfoAtPosition } from './types'; import { SimplePosition } from './simple-position'; export function getQuickInfoAtPosition( diff --git a/src/graphql-language-service-adapter/get-semantic-diagnostics.ts b/src/graphql-language-service-adapter/get-semantic-diagnostics.ts index a5a2b20f9..45f5ed656 100644 --- a/src/graphql-language-service-adapter/get-semantic-diagnostics.ts +++ b/src/graphql-language-service-adapter/get-semantic-diagnostics.ts @@ -3,7 +3,7 @@ import type { FragmentDefinitionNode } from 'graphql'; import { getDiagnostics, type Diagnostic } from 'graphql-language-service'; import { SchemaBuildErrorInfo } from '../schema-manager/schema-manager'; import { ERROR_CODES } from '../errors'; -import { AnalysisContext, GetSemanticDiagnostics } from './types'; +import type { AnalysisContext, GetSemanticDiagnostics } from './types'; import { getSanitizedTemplateText } from '../ts-ast-util'; import { getFragmentsInDocument } from '../gql-ast-util'; import { OutOfRangeError } from '../string-util'; diff --git a/src/graphql-language-service-adapter/graphql-language-service-adapter.ts b/src/graphql-language-service-adapter/graphql-language-service-adapter.ts index adcab52a8..c2218aeda 100644 --- a/src/graphql-language-service-adapter/graphql-language-service-adapter.ts +++ b/src/graphql-language-service-adapter/graphql-language-service-adapter.ts @@ -1,15 +1,15 @@ import ts from 'typescript'; -import { GraphQLSchema, parse, type DocumentNode } from 'graphql'; +import { parse, type GraphQLSchema, type DocumentNode } from 'graphql'; import { getTemplateNodeUnder, isTaggedTemplateNode, - ScriptSourceHelper, - StrictTagCondition, isTemplateLiteralTypeNode, + type ScriptSourceHelper, + type StrictTagCondition, } from '../ts-ast-util'; -import { SchemaBuildErrorInfo } from '../schema-manager/schema-manager'; +import type { SchemaBuildErrorInfo } from '../schema-manager/schema-manager'; import { getFragmentNamesInDocument, detectDuplicatedFragments, type FragmentRegistry } from '../gql-ast-util'; -import { AnalysisContext, GetCompletionAtPosition, GetSemanticDiagnostics, GetQuickInfoAtPosition } from './types'; +import type { AnalysisContext, GetCompletionAtPosition, GetSemanticDiagnostics, GetQuickInfoAtPosition } from './types'; import { getCompletionAtPosition } from './get-completion-at-position'; import { getSemanticDiagnostics } from './get-semantic-diagnostics'; import { getQuickInfoAtPosition } from './get-quick-info-at-position'; @@ -24,8 +24,6 @@ export interface GraphQLLanguageServiceAdapterCreateOptions { fragmentRegistry: FragmentRegistry; } -type Args = T extends (...args: infer A) => any ? A : never; - export class GraphQLLanguageServiceAdapter { private _schemaErrors?: SchemaBuildErrorInfo[] | null; private _schema?: GraphQLSchema | null; @@ -48,15 +46,15 @@ export class GraphQLLanguageServiceAdapter { this._fragmentRegisry = opt.fragmentRegistry; } - getCompletionAtPosition(delegate: GetCompletionAtPosition, ...args: Args) { + getCompletionAtPosition(delegate: GetCompletionAtPosition, ...args: Parameters) { return getCompletionAtPosition(this._analysisContext, delegate, ...args); } - getSemanticDiagnostics(delegate: GetSemanticDiagnostics, ...args: Args) { + getSemanticDiagnostics(delegate: GetSemanticDiagnostics, ...args: Parameters) { return getSemanticDiagnostics(this._analysisContext, delegate, ...args); } - getQuickInfoAtPosition(delegate: GetQuickInfoAtPosition, ...args: Args) { + getQuickInfoAtPosition(delegate: GetQuickInfoAtPosition, ...args: Parameters) { return getQuickInfoAtPosition(this._analysisContext, delegate, ...args); } diff --git a/src/graphql-language-service-adapter/types.ts b/src/graphql-language-service-adapter/types.ts index 0586340f4..9c3225d4d 100644 --- a/src/graphql-language-service-adapter/types.ts +++ b/src/graphql-language-service-adapter/types.ts @@ -1,7 +1,7 @@ -import ts from 'typescript'; -import { GraphQLSchema, type DocumentNode, type FragmentDefinitionNode } from 'graphql'; -import { ScriptSourceHelper, ResolveResult } from '../ts-ast-util'; -import { SchemaBuildErrorInfo } from '../schema-manager/schema-manager'; +import type ts from 'typescript'; +import type { GraphQLSchema, DocumentNode, FragmentDefinitionNode } from 'graphql'; +import type { ScriptSourceHelper, ResolveResult } from '../ts-ast-util'; +import type { SchemaBuildErrorInfo } from '../schema-manager/schema-manager'; export type GetCompletionAtPosition = ts.LanguageService['getCompletionsAtPosition']; export type GetSemanticDiagnostics = ts.LanguageService['getSemanticDiagnostics']; diff --git a/src/language-service-plugin/language-service-proxy-builder.ts b/src/language-service-plugin/language-service-proxy-builder.ts index 5deaa351f..ca0c7d72e 100644 --- a/src/language-service-plugin/language-service-proxy-builder.ts +++ b/src/language-service-plugin/language-service-proxy-builder.ts @@ -1,4 +1,4 @@ -import ts from 'typescript/lib/tsserverlibrary'; +import type ts from 'typescript/lib/tsserverlibrary'; export type LanguageServiceMethodWrapper = ( delegate: ts.LanguageService[K], diff --git a/src/language-service-plugin/plugin-module-factory.ts b/src/language-service-plugin/plugin-module-factory.ts index f845b6b6c..2e2b4cce7 100644 --- a/src/language-service-plugin/plugin-module-factory.ts +++ b/src/language-service-plugin/plugin-module-factory.ts @@ -1,5 +1,5 @@ import ts from 'typescript/lib/tsserverlibrary'; -import { TsGraphQLPluginConfigOptions } from '../types'; +import type { TsGraphQLPluginConfigOptions } from '../types'; import { GraphQLLanguageServiceAdapter } from '../graphql-language-service-adapter'; import { SchemaManagerFactory, createSchemaManagerHostFromLSPluginInfo } from '../schema-manager'; import { FragmentRegistry } from '../gql-ast-util'; diff --git a/src/register-hooks/register-typescript.ts b/src/register-hooks/register-typescript.ts index ee49cf4f5..93c15180e 100644 --- a/src/register-hooks/register-typescript.ts +++ b/src/register-hooks/register-typescript.ts @@ -1,5 +1,5 @@ +import fs from 'node:fs'; import type { CompilerOptions } from 'typescript'; -import fs from 'fs'; export function registerTypeScript() { let defaultCompileOptions: CompilerOptions; diff --git a/src/schema-manager/extension-manager.ts b/src/schema-manager/extension-manager.ts index c50ccabb2..0109fb0b4 100644 --- a/src/schema-manager/extension-manager.ts +++ b/src/schema-manager/extension-manager.ts @@ -1,7 +1,7 @@ -import path from 'path'; -import { GraphQLSchema, parse, extendSchema, DocumentNode, GraphQLError } from 'graphql'; -import { SchemaBuildErrorInfo } from './schema-manager'; -import { SchemaManagerHost } from './types'; +import path from 'node:path'; +import { parse, extendSchema, GraphQLError, type GraphQLSchema, type DocumentNode } from 'graphql'; +import type { SchemaBuildErrorInfo } from './schema-manager'; +import type { SchemaManagerHost } from './types'; export class ExtensionManager { private _targetSdlFileNames: string[]; diff --git a/src/schema-manager/file-schema-manager.ts b/src/schema-manager/file-schema-manager.ts index 545fa1285..fa9dce079 100644 --- a/src/schema-manager/file-schema-manager.ts +++ b/src/schema-manager/file-schema-manager.ts @@ -1,9 +1,9 @@ -import path from 'path'; -import ts from 'typescript/lib/tsserverlibrary'; +import path from 'node:path'; +import type ts from 'typescript'; import { buildSchema, buildClientSchema } from 'graphql'; import { SchemaManager } from './schema-manager'; -import { SchemaManagerHost } from './types'; +import type { SchemaManagerHost } from './types'; function extractIntrospectionContentFromJson(jsonObject: any) { if (jsonObject.data) { diff --git a/src/schema-manager/http-schema-manager.ts b/src/schema-manager/http-schema-manager.ts index b9a120e91..2f4830343 100644 --- a/src/schema-manager/http-schema-manager.ts +++ b/src/schema-manager/http-schema-manager.ts @@ -1,5 +1,5 @@ import { SchemaManager } from './schema-manager'; -import { SchemaManagerHost } from './types'; +import type { SchemaManagerHost } from './types'; import { requestIntrospectionQuery, type RequestSetup } from './request-introspection-query'; export class HttpSchemaManager extends SchemaManager { diff --git a/src/schema-manager/request-introspection-query.ts b/src/schema-manager/request-introspection-query.ts index 20b38c46c..a4ebb71e4 100644 --- a/src/schema-manager/request-introspection-query.ts +++ b/src/schema-manager/request-introspection-query.ts @@ -1,7 +1,7 @@ -import { GraphQLSchema, buildClientSchema, getIntrospectionQuery } from 'graphql'; -import { parse } from 'url'; -import Http from 'http'; -import Https from 'https'; +import { parse } from 'node:url'; +import Http from 'node:http'; +import Https from 'node:https'; +import { buildClientSchema, getIntrospectionQuery, type GraphQLSchema } from 'graphql'; const INTROSPECTION_QUERY_BODY = JSON.stringify({ query: getIntrospectionQuery(), diff --git a/src/schema-manager/schema-manager-factory.ts b/src/schema-manager/schema-manager-factory.ts index f61da51ac..b735618ba 100644 --- a/src/schema-manager/schema-manager-factory.ts +++ b/src/schema-manager/schema-manager-factory.ts @@ -1,4 +1,4 @@ -import { SchemaManagerHost } from './types'; +import type { SchemaManagerHost } from './types'; import { SchemaManager, NoopSchemaManager } from './schema-manager'; import { FileSchemaManagerOptions, FileSchemaManager } from './file-schema-manager'; import { HttpSchemaManager } from './http-schema-manager'; diff --git a/src/schema-manager/schema-manager-host.ts b/src/schema-manager/schema-manager-host.ts index 226371524..f424cb566 100644 --- a/src/schema-manager/schema-manager-host.ts +++ b/src/schema-manager/schema-manager-host.ts @@ -1,7 +1,7 @@ -import ts from 'typescript/lib/tsserverlibrary'; -import path from 'path'; -import { SchemaManagerHost, SchemaConfig } from './types'; -import { TsGraphQLPluginConfigOptions } from '../types'; +import path from 'node:path'; +import ts from 'typescript'; +import type { SchemaManagerHost, SchemaConfig } from './types'; +import type { TsGraphQLPluginConfigOptions } from '../types'; class SystemSchemaManagerHost implements SchemaManagerHost { constructor( diff --git a/src/schema-manager/schema-manager.ts b/src/schema-manager/schema-manager.ts index 09b7b37f4..e585084a3 100644 --- a/src/schema-manager/schema-manager.ts +++ b/src/schema-manager/schema-manager.ts @@ -1,6 +1,6 @@ -import { GraphQLSchema } from 'graphql'; +import type { GraphQLSchema } from 'graphql'; import { ExtensionManager } from './extension-manager'; -import { SchemaManagerHost } from './types'; +import type { SchemaManagerHost } from './types'; export type SchemaBuildErrorInfo = { message: string; diff --git a/src/schema-manager/scripted-http-schema-manager.ts b/src/schema-manager/scripted-http-schema-manager.ts index 952172b26..9cbff12d2 100644 --- a/src/schema-manager/scripted-http-schema-manager.ts +++ b/src/schema-manager/scripted-http-schema-manager.ts @@ -1,6 +1,6 @@ -import { SchemaManagerHost } from './types'; +import { join, isAbsolute } from 'node:path'; +import type { SchemaManagerHost } from './types'; import { RequestSetup, isRequestSetup } from './request-introspection-query'; -import { join, isAbsolute } from 'path'; import { HttpSchemaManager } from './http-schema-manager'; interface ScriptedHttpSchemaManagerOptions { diff --git a/src/transformer/transformer-host.ts b/src/transformer/transformer-host.ts index c93635d22..d44ec934d 100644 --- a/src/transformer/transformer-host.ts +++ b/src/transformer/transformer-host.ts @@ -1,10 +1,10 @@ -import ts from 'typescript'; -import { Kind, type DocumentNode, FragmentDefinitionNode } from 'graphql'; +import type ts from 'typescript'; +import { Kind, type DocumentNode, type FragmentDefinitionNode } from 'graphql'; import { getFragmentDependenciesForAST } from 'graphql-language-service'; -import { Analyzer, AnalyzerFactory, ExtractFileResult } from '../analyzer'; -import { getTransformer, DocumentTransformer } from './transformer'; +import { AnalyzerFactory, type Analyzer, type ExtractFileResult } from '../analyzer'; import { parseTagConfig } from '../ts-ast-util'; import { cloneFragmentMap, getFragmentNamesInDocument } from '../gql-ast-util'; +import { getTransformer, type DocumentTransformer } from './transformer'; class DocumentNodeRegistory { protected readonly _map = new Map>(); diff --git a/src/transformer/transformer.ts b/src/transformer/transformer.ts index 6f724c5f4..974d8e907 100644 --- a/src/transformer/transformer.ts +++ b/src/transformer/transformer.ts @@ -1,5 +1,5 @@ import ts from 'typescript'; -import { DocumentNode, print } from 'graphql'; +import { print, type DocumentNode } from 'graphql'; import { astf, getTemplateNodeUnder, removeAliasFromImportDeclaration, type StrictTagCondition } from '../ts-ast-util'; export type DocumentTransformer = (documentNode: DocumentNode) => DocumentNode; diff --git a/src/ts-ast-util/output-source.ts b/src/ts-ast-util/output-source.ts index 5ae407a32..d65502486 100644 --- a/src/ts-ast-util/output-source.ts +++ b/src/ts-ast-util/output-source.ts @@ -1,10 +1,9 @@ -import path from 'path'; +import path from 'node:path'; import ts from 'typescript'; -import { OutputSource } from './types'; -import { isImportDeclarationWithCondition, mergeImportDeclarationsWithSameModules } from './utilily-functions'; - +import type { OutputSource } from './types'; import { astf } from './ast-factory-alias'; +import { isImportDeclarationWithCondition, mergeImportDeclarationsWithSameModules } from './utilily-functions'; const printer = ts.createPrinter(); diff --git a/src/ts-ast-util/script-source-helper.ts b/src/ts-ast-util/script-source-helper.ts index 7beb3fea6..3eca28ec4 100644 --- a/src/ts-ast-util/script-source-helper.ts +++ b/src/ts-ast-util/script-source-helper.ts @@ -1,8 +1,8 @@ import ts from 'typescript'; -import { ScriptSourceHelper } from './types'; import { findAllNodes, findNode } from './utilily-functions'; import { TemplateExpressionResolver } from './template-expression-resolver'; import { createFileNameFilter } from './file-name-filter'; +import type { ScriptSourceHelper } from './types'; export function createScriptSourceHelper( { diff --git a/src/ts-ast-util/template-expression-resolver.ts b/src/ts-ast-util/template-expression-resolver.ts index 6f0e3c81e..7812d34ce 100644 --- a/src/ts-ast-util/template-expression-resolver.ts +++ b/src/ts-ast-util/template-expression-resolver.ts @@ -1,7 +1,7 @@ import ts from 'typescript'; import { location2pos, pos2location } from '../string-util'; import { findNode } from './utilily-functions'; -import { ComputePosition, ResolvedTemplateInfo, ResolveResult, ResolveErrorInfo } from './types'; +import type { ComputePosition, ResolvedTemplateInfo, ResolveResult, ResolveErrorInfo } from './types'; const last: ComputePosition = (pos: number) => { throw new Error('invalid range: ' + pos); diff --git a/src/ts-ast-util/types.ts b/src/ts-ast-util/types.ts index 45a8d5fc7..98ee1575f 100644 --- a/src/ts-ast-util/types.ts +++ b/src/ts-ast-util/types.ts @@ -1,4 +1,4 @@ -import ts from 'typescript'; +import type ts from 'typescript'; /** * diff --git a/src/typegen-addons/typed-query-document.ts b/src/typegen-addons/typed-query-document.ts index a97eefbcf..bb9d529c4 100644 --- a/src/typegen-addons/typed-query-document.ts +++ b/src/typegen-addons/typed-query-document.ts @@ -1,5 +1,5 @@ import ts from 'typescript'; -import { TypeGenAddonFactory } from '../typegen'; +import type { TypeGenAddonFactory } from '../typegen'; import { astf } from '../ts-ast-util'; export const TypedQueryDocumentAddonFactory: TypeGenAddonFactory = ({ source }) => ({ diff --git a/src/typegen/type-gen-visitor.ts b/src/typegen/type-gen-visitor.ts index 644d42479..518e79089 100644 --- a/src/typegen/type-gen-visitor.ts +++ b/src/typegen/type-gen-visitor.ts @@ -1,12 +1,7 @@ import ts from 'typescript'; import { + visit, GraphQLSchema, - DocumentNode, - FieldNode, - FragmentDefinitionNode, - ASTNode, - NamedTypeNode, - TypeNode, GraphQLScalarType, GraphQLEnumType, GraphQLObjectType, @@ -19,10 +14,15 @@ import { GraphQLInputField, GraphQLInputType, GraphQLOutputType, + type ASTNode, + type DocumentNode, + type FragmentDefinitionNode, + type FieldNode, + type NamedTypeNode, + type TypeNode, } from 'graphql'; -import { visit } from 'graphql/language'; -import { astf, OutputSource } from '../ts-ast-util'; -import { StrictAddon } from './addon/types'; +import { astf, type OutputSource } from '../ts-ast-util'; +import type { StrictAddon } from './addon/types'; class Stack { private _array: T[] = []; diff --git a/src/webpack/plugin.ts b/src/webpack/plugin.ts index f95d5f3af..0fe5a5e19 100644 --- a/src/webpack/plugin.ts +++ b/src/webpack/plugin.ts @@ -1,6 +1,6 @@ import path from 'path'; -import { Compiler } from 'webpack'; -import { TransformerHost, GetTransformerOptions } from '../transformer'; +import type { Compiler } from 'webpack'; +import { TransformerHost, type GetTransformerOptions } from '../transformer'; type WatchFileSystemCompiler = Compiler & { watchFileSystem: { diff --git a/tools/add-toc.ts b/tools/add-toc.ts index eca503bdc..8a9a2ea9a 100644 --- a/tools/add-toc.ts +++ b/tools/add-toc.ts @@ -1,5 +1,5 @@ -import fs from 'fs'; -import path from 'path'; +import fs from 'node:fs'; +import path from 'node:path'; const toc = require('markdown-toc');