Skip to content

dominikg/tsconfck

Folders and files

NameName
Last commit message
Last commit date
Feb 6, 2025
May 23, 2024
Aug 22, 2024
Jan 21, 2025
Mar 28, 2025
Jul 11, 2024
Aug 14, 2021
Aug 18, 2023
Oct 12, 2023
Aug 18, 2023
Aug 19, 2023
Aug 18, 2023
Aug 31, 2024
Jun 11, 2024
Mar 28, 2025
Mar 28, 2025
Aug 18, 2023

Repository files navigation

tsconfck

npm version CI

A utility to find and parse tsconfig files without depending on typescript

Why

Because no simple official api exists and tsconfig isn't actual json.

Features

  • find closest tsconfig (tsconfig.json or jsconfig.json)
  • convert tsconfig to actual json and parse it
  • resolve "extends"
  • resolve "references" of solution-style tsconfig
  • resolve "${configDir}" variable
  • optional caching for improved performance
  • optional findNative and parseNative to use official typescript api
  • zero dependencies (typescript optional)
  • extensive testsuite
  • completely async and optimized (it's fast)
  • tiny 4.7KB gzip
  • unbundled esm js, no sourcemaps needed
  • types generated with dts-buddy

Users

Used by vite*, vite-tsconfig-paths, astro and many more

(*) vite bundles tsconfck so it is listed as a devDependency

Install

npm install --save-dev tsconfck # or pnpm, yarn

Usage

import { parse } from 'tsconfck';
const {
	tsconfigFile, // full path to found tsconfig
	tsconfig, // tsconfig object including merged values from extended configs
	extended, // separate unmerged results of all tsconfig files that contributed to tsconfig
	solution, // solution result if tsconfig is part of a solution
	referenced // referenced tsconfig results if tsconfig is a solution
} = await parse('foo/bar.ts');

Links

package readme api changelog

Develop

This repo uses

In every PR you have to add a changeset by running pnpm changeset and following the prompts

PRs are going to be squash-merged

# install dependencies
pnpm install
# run tests
pnpm test

License

MIT