Gathering detailed insights and metrics for tsconfck
Gathering detailed insights and metrics for tsconfck
Gathering detailed insights and metrics for tsconfck
Gathering detailed insights and metrics for tsconfck
A utility to find and parse tsconfig files without depending on typescript
npm install tsconfck
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.3
Supply Chain
100
Quality
80.5
Maintenance
100
Vulnerability
99.6
License
tsconfck@3.1.5
Updated on Feb 06, 2025
tsconfck@3.1.4
Updated on Oct 10, 2024
tsconfck@3.1.3
Updated on Aug 31, 2024
tsconfck@3.1.2
Updated on Aug 31, 2024
tsconfck@3.1.1
Updated on Jun 27, 2024
tsconfck@3.1.0
Updated on May 29, 2024
JavaScript (100%)
Total Downloads
210,565,201
Last Day
525,889
Last Week
3,830,030
Last Month
17,419,229
Last Year
144,915,156
NOASSERTION License
309 Stars
256 Commits
15 Forks
2 Watchers
7 Branches
10 Contributors
Updated on Apr 14, 2025
Latest Version
3.1.5
Package Id
tsconfck@3.1.5
Unpacked Size
67.88 kB
Size
18.10 kB
File Count
16
NPM Version
10.8.2
Node Version
20.18.2
Published on
Feb 06, 2025
Cumulative downloads
Total Downloads
Last Day
-34.6%
525,889
Compared to previous day
Last Week
2.1%
3,830,030
Compared to previous week
Last Month
3.8%
17,419,229
Compared to previous month
Last Year
143.3%
144,915,156
Compared to previous year
1
A utility to find and parse tsconfig files without depending on typescript
Because no simple official api exists and tsconfig isn't actual json.
Used by vite*, vite-tsconfig-paths, astro and many more
(*) vite bundles tsconfck so it is listed as a devDependency
1npm install --save-dev tsconfck # or pnpm, yarn
1import { parse } from 'tsconfck'; 2const { 3 tsconfigFile, // full path to found tsconfig 4 tsconfig, // tsconfig object including merged values from extended configs 5 extended, // separate unmerged results of all tsconfig files that contributed to tsconfig 6 solution, // solution result if tsconfig is part of a solution 7 referenced // referenced tsconfig results if tsconfig is a solution 8} = await parse('foo/bar.ts');
1import { parseNative } from 'tsconfck'; 2const { 3 tsconfigFile, // full path to found tsconfig 4 tsconfig, // tsconfig object including merged values from extended configs, normalized 5 result, // output of ts.parseJsonConfigFileContent 6 solution, // solution result if tsconfig is part of a solution 7 referenced // referenced tsconfig results if tsconfig is a solution 8} = await parseNative('foo/bar.ts');
see API-DOCS
esbuild ignores node_modules so when you want to use tsconfck with esbuild, you can set ignoreNodeModules: true
1import { find, parse } from 'tsconfck'; 2// returns some-lib/tsconfig.json 3const fooTSConfig = await find('node_modules/some-lib/src/foo.ts'); 4 5// returns null 6const fooTSConfigIgnored = await find('node_modules/some-lib/src/foo.ts', { 7 ignoreNodeModules: true 8}); 9 10// returns empty config 11const { tsconfig } = await parse('node_modules/some-lib/src/foo.ts', { ignoreNodeModules: true });
a TSConfckCache instance can be created and passed to find and parse functions to reduce overhead when they are called often within the same project
1import { find, parse, TSCOnfckCache } from 'tsconfck'; 2// 1. create cache instance 3const cache = new TSCOnfckCache(); 4// 2. pass cache instance in options 5const fooTSConfig = await find(('src/foo.ts', { cache })); // stores tsconfig for src in cache 6const barTSConfig = await find(('src/bar.ts', { cache })); // reuses tsconfig result for src without fs call 7 8const fooResult = await parse('src/foo.ts', { cache }); // uses cached path for tsconfig, stores parse result in cache 9const barResult = await parse('src/bar.ts', { cache }); // uses cached parse result without fs call or resolving
You are responsible for clearing the cache if tsconfig files are added/removed/changed after reading them during the cache lifetime.
Call cache.clear()
and also discard all previous compilation results based previously cached configs.
Returned results are direct cache objects. If you want to modify them, deep-clone first.
Never use the same cache instance for mixed calls of find/findNative or parse/parseNative as result structures are different
This option can be used to limit finding tsconfig files outside of a root directory
1import { parse, TSConfckCache } from 'tsconfck'; 2const root = '.'; 3const parseOptions = { root }; 4// these calls are not going to look for tsconfig files outside root 5const fooResult = await find('src/foo.ts', parseOptions); 6const barResult = await parse('src/bar.ts', parseOptions);
Using the root option can lead to errors if there is no tsconfig found inside root.
find and parse reject for errors they encounter, but return null or empty result if no config was found
If you want them to error instead, test the result and throw
1import { parse } from 'tsconfck'; 2find('some/path/without/tsconfig/foo.ts').then((result) => { 3 if (result === null) { 4 throw new Error('not found'); 5 } 6 return result; 7}); 8parse('some/path/without/tsconfig/foo.ts').then((result) => { 9 if (result.tsconfigFile === null) { 10 throw new Error('not found'); 11 } 12 return result; 13});
1import type { TSConfig } from 'pkg-types';
Check out https://github.com/unjs/pkg-types
A simple cli wrapper is included, you can use it like this
1# prints /path/to/tsconfig.json on stdout 2tsconfck find src/index.ts
1# prints all tsconfig.json in dir on stdout 2tsconfck find-all src/
1# print content of ParseResult.tsconfig on stdout 2tsconfck parse src/index.ts 3 4# print to file 5tsconfck parse src/index.ts > output.json
1# print content of ParseResult on stdout 2tsconfck parse-result src/index.ts 3 4# print to file 5tsconfck parse-result src/index.ts > output.json
1# print usage 2tsconfck -h # or --help, -?, help
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
1# install dependencies 2pnpm install 3# run tests 4pnpm test 5#run tests in watch mode (doesn't require dev in parallel) 6pnpm test:watch
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
6 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 6
Reason
7 existing vulnerabilities detected
Details
Reason
Found 3/13 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-28
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More