# core/resolvers/program.resolver.ts

> 15 lines of code and 4 definitions.

Tree: GovLab Docs
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/docs#file-docs-core-resolvers-program-resolver-ts
Source text: https://banes-lab.com/source/docs/core/resolvers/program.resolver.ts.txt

Listed in [core/resolvers](https://banes-lab.com/api/source/docs/core/resolvers.md), after [core/resolvers/location.resolver.ts](https://banes-lab.com/source/docs/core/resolvers/location.resolver.ts.md) and before [core/resolvers/source.resolver.ts](https://banes-lab.com/source/docs/core/resolvers/source.resolver.ts.md).

## Definitions

- `moduleCompilerOptions` (lexical_declaration, line 5, exported)
- `configPath` (lexical_declaration, line 6, exported)
- `read` (lexical_declaration, line 10, exported)
- `parsed` (lexical_declaration, line 14, exported)

## Contained in

- [core/resolvers](https://banes-lab.com/anatomy/docs/folder-docs-core-resolvers.md)

## Source

```typescript
import { PROGRAM_OPTIONS, PROGRAM_OVERRIDES } from "#configuration/constants/program.constants";
import { dirname } from "node:path";
import ts from "typescript";

export const moduleCompilerOptions = function moduleCompilerOptions(moduleDir: string): ts.CompilerOptions {
    const configPath = ts.findConfigFile(moduleDir, (file) => ts.sys.fileExists(file));
    if (configPath === undefined) {
        return PROGRAM_OPTIONS;
    }
    const read = ts.readConfigFile(configPath, (file) => ts.sys.readFile(file));
    if (read.error !== undefined) {
        return PROGRAM_OPTIONS;
    }
    const parsed = ts.parseJsonConfigFileContent(read.config, ts.sys, dirname(configPath), {}, configPath);
    return { ...PROGRAM_OPTIONS, ...parsed.options, ...PROGRAM_OVERRIDES };
};
```
