TsconfigUsage
Usage
Last updated:
Usage Guide
Find tsconfig.json
import { findTsConfig } from "@visulima/tsconfig";
const result = await findTsConfig();
// => {
// path: "/path/to/tsconfig.json",
// config: { compilerOptions: { ... } }
// }
// From specific directory
const result2 = await findTsConfig("/path/to/project");Read tsconfig.json
import { readTsConfig } from "@visulima/tsconfig";
const config = await readTsConfig("/path/to/tsconfig.json");
// TypeScript compatible mode
const config2 = await readTsConfig("/path/to/tsconfig.json", {
tscCompatible: true,
});Write tsconfig.json
import { writeTsConfig } from "@visulima/tsconfig";
await writeTsConfig({
compilerOptions: {
target: "ES2022",
module: "ESNext",
moduleResolution: "bundler",
strict: true,
},
});
// Custom path
await writeTsConfig(config, { cwd: "./packages/app" });Extends Resolution
import { readTsConfig } from "@visulima/tsconfig";
// Automatically resolves extends
const config = await readTsConfig("/path/to/tsconfig.json");
// Merges base configurations from extends field