or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration.mdindex.mdtype-generation.mdutility-types.mdvisitors.md
tile.json

configuration.mddocs/

Plugin Configuration

The TypeScript plugin provides extensive configuration options to customize how GraphQL types are converted to TypeScript. All configuration options are optional and have sensible defaults.

Capabilities

Configuration Interface

Main configuration interface extending the base RawTypesConfig with TypeScript-specific options.

/**
 * Main configuration interface for the TypeScript plugin
 * Extends RawTypesConfig with TypeScript-specific options
 */
interface TypeScriptPluginConfig extends RawTypesConfig {
  avoidOptionals?: boolean | AvoidOptionalsConfig;
  constEnums?: boolean;
  enumsAsTypes?: boolean;
  numericEnums?: boolean;
  futureProofEnums?: boolean;
  futureProofUnions?: boolean;
  enumsAsConst?: boolean;
  onlyEnums?: boolean;
  onlyOperationTypes?: boolean;
  immutableTypes?: boolean;
  maybeValue?: string;
  inputMaybeValue?: string;
  noExport?: boolean;
  disableDescriptions?: boolean;
  useImplementingTypes?: boolean;
  wrapEntireFieldDefinitions?: boolean;
  entireFieldWrapperValue?: string;
  allowEnumStringTypes?: boolean;
}

Optional Type Handling

Controls how optional and nullable types are generated in TypeScript.

/**
 * Controls TypeScript optional handling
 * @default false
 */
avoidOptionals?: boolean | AvoidOptionalsConfig;

Usage Examples:

// Avoid all optionals
const config = {
  avoidOptionals: true
};
// Output: myField: Maybe<string> instead of myField?: Maybe<string>

// Granular control
const config = {
  avoidOptionals: {
    field: true,
    inputValue: true,
    object: true,
    defaultValue: true
  }
};

Enum Generation Options

Multiple strategies for generating TypeScript enums from GraphQL enums.

/**
 * Generate const enums instead of regular enums
 * @default false
 */
constEnums?: boolean;

/**
 * Generate enums as TypeScript string union types
 * @default false
 */
enumsAsTypes?: boolean;

/**
 * Generate enums as const assertions
 * @default false
 */
enumsAsConst?: boolean;

/**
 * Preserve numeric enum values
 * @default false
 */
numericEnums?: boolean;

Usage Examples:

// Regular enum (default)
enum Status {
  Active = "ACTIVE",
  Inactive = "INACTIVE"
}

// With constEnums: true
const enum Status {
  Active = "ACTIVE",
  Inactive = "INACTIVE"
}

// With enumsAsTypes: true
type Status = "ACTIVE" | "INACTIVE";

// With enumsAsConst: true
const Status = {
  Active: "ACTIVE",
  Inactive: "INACTIVE"
} as const;

Future-Proofing Options

Add catch-all entries for future schema changes.

/**
 * Add catch-all entry to enum type definitions
 * @default false
 */
futureProofEnums?: boolean;

/**
 * Add catch-all entry to union type definitions  
 * @default false
 */
futureProofUnions?: boolean;

Usage Examples:

// With futureProofEnums: true
type Status = "ACTIVE" | "INACTIVE" | "%future added value";

// With futureProofUnions: true
type Node = User | Post | "%future added value";

Type Generation Filtering

Control which types are generated.

/**
 * Generate only enum types
 * @default false
 */
onlyEnums?: boolean;

/**
 * Generate only operation types (enums and scalars)
 * @default false
 */
onlyOperationTypes?: boolean;

Immutability Options

Generate readonly types for immutable data structures.

/**
 * Generate immutable types with readonly properties
 * @default false
 */
immutableTypes?: boolean;

Usage Examples:

// With immutableTypes: false (default)
type User = {
  name: string;
  tags: string[];
};

// With immutableTypes: true
type User = {
  readonly name: string;
  readonly tags: ReadonlyArray<string>;
};

Maybe Type Customization

Customize the Maybe type wrapper for nullable values.

/**
 * Override Maybe type definition
 * @default "T | null"
 */
maybeValue?: string;

/**
 * Override InputMaybe type definition for input types
 * @default "Maybe<T>"
 */
inputMaybeValue?: string;

Usage Examples:

// Allow undefined
const config = {
  maybeValue: "T | null | undefined"
};

// Custom resolver handling
const config = {
  maybeValue: "T extends PromiseLike<infer U> ? Promise<U | null> : T | null"
};

Export and Description Options

Control code generation style.

/**
 * Generate without export modifiers
 * @default false
 */
noExport?: boolean;

/**
 * Disable all description generation
 * @default false
 */
disableDescriptions?: boolean;

Advanced Type Options

Advanced TypeScript type generation features.

/**
 * Use implementing types instead of interfaces
 * @default false
 */
useImplementingTypes?: boolean;

/**
 * Wrap entire field definitions with EntireFieldWrapper
 * @default false
 */
wrapEntireFieldDefinitions?: boolean;

/**
 * Override EntireFieldWrapper type definition
 * @default "T"
 */
entireFieldWrapperValue?: string;

/**
 * Allow enum string values directly
 * @default false
 */
allowEnumStringTypes?: boolean;