# types/code.types.ts

> 40 lines of code and 7 definitions.

Tree: Site tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/tree#file-types-code-types-ts
Source text: https://banes-lab.com/source/tree/types/code.types.ts.txt

Listed in [types](https://banes-lab.com/api/source/tree/types.md), after [types/card.types.ts](https://banes-lab.com/source/tree/types/card.types.ts.md) and before [types/coverage.types.ts](https://banes-lab.com/source/tree/types/coverage.types.ts.md).

## Definitions

- `TemplateParts` (interface_declaration, line 3, exported)
- `CandidateLocation` (interface_declaration, line 8, exported)
- `CodeTarget` (type_alias_declaration, line 14, exported)
- `Binding` (interface_declaration, line 21, exported)
- `CodeFile` (interface_declaration, line 30, exported)
- `ReferenceLookups` (interface_declaration, line 35, exported)
- `SourceReferences` (interface_declaration, line 41, exported)

## Source

```typescript
import type { DefinitionLocation } from "#types/anatomy.types";

export interface TemplateParts {
    readonly holes: readonly string[];
    readonly literals: readonly string[];
}

export interface CandidateLocation {
    readonly file: string;
    readonly line: number | null;
    readonly name: string;
}

export type CodeTarget =
    | { readonly kind: "candidates"; readonly locations: readonly CandidateLocation[] }
    | { readonly kind: "definition"; readonly location: DefinitionLocation }
    | { readonly kind: "file"; readonly path: string }
    | { readonly kind: "folder"; readonly path: string }
    | { readonly kind: "record"; readonly ref: string };

export interface Binding {
    readonly column: number;
    readonly file: string;
    readonly line: number;
    readonly module: boolean;
    readonly name: string;
    readonly target: number;
}

export interface CodeFile {
    readonly absolute: string;
    readonly path: string;
}

export interface ReferenceLookups {
    readonly bindings: (path: string) => readonly Binding[] | null;
    readonly records: ReadonlySet<string>;
    readonly ruleRecord: (text: string) => string | null;
}

export interface SourceReferences {
    readonly sites: readonly number[];
    readonly spans: Readonly<Record<string, CodeTarget>>;
    readonly strings: Readonly<Record<string, CodeTarget>>;
    readonly targets: readonly CodeTarget[];
    readonly words: Readonly<Record<string, CodeTarget>>;
}
```
