Gathering detailed insights and metrics for @unts/get-tsconfig
Gathering detailed insights and metrics for @unts/get-tsconfig
Gathering detailed insights and metrics for @unts/get-tsconfig
Gathering detailed insights and metrics for @unts/get-tsconfig
Lightweight tsconfig.json parser & paths resolver
npm install @unts/get-tsconfig
Typescript
Module System
Node Version
NPM Version
86.6
Supply Chain
99.1
Quality
74.8
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
2,158,420
Last Day
245
Last Week
4,277
Last Month
16,169
Last Year
201,581
MIT License
221 Stars
150 Commits
17 Forks
4 Watchers
3 Branches
13 Contributors
Updated on Jun 30, 2025
Minified
Minified + Gzipped
Latest Version
4.1.1
Package Id
@unts/get-tsconfig@4.1.1
Unpacked Size
52.88 kB
Size
14.75 kB
File Count
6
NPM Version
8.5.0
Node Version
16.14.2
Cumulative downloads
Total Downloads
Last Day
-35.9%
245
Compared to previous day
Last Week
-2.5%
4,277
Compared to previous week
Last Month
-0.1%
16,169
Compared to previous month
Last Year
-58%
201,581
Compared to previous year
Find and parse tsconfig.json
files.
tsconfig.json
extends
tsconfig.json
3.6 kB
Minified + Gzipped1npm install get-tsconfig
For TypeScript related tooling to correctly parse tsconfig.json
file without depending on TypeScript.
Searches for a tsconfig.json
file and parses it. Returns null
if a config file cannot be found, or an object containing the path and parsed TSConfig object if found.
Returns:
1type TsconfigResult = { 2 /** 3 * The path to the tsconfig.json file 4 */ 5 path: string 6 7 /** 8 * The resolved tsconfig.json file 9 */ 10 config: TsConfigJsonResolved 11}
Type: string
Default: process.cwd()
Accepts a path to a file or directory to search up for a tsconfig.json
file.
Type: string
Default: tsconfig.json
The file name of the TypeScript config file.
1import { getTsconfig } from 'get-tsconfig'
2
3// Searches for tsconfig.json starting in the current directory
4console.log(getTsconfig())
5
6// Find tsconfig.json from a TypeScript file path
7console.log(getTsconfig('./path/to/index.ts'))
8
9// Find tsconfig.json from a directory file path
10console.log(getTsconfig('./path/to/directory'))
11
12// Explicitly pass in tsconfig.json path
13console.log(getTsconfig('./path/to/tsconfig.json'))
The tsconfig.json
parser used internally by getTsconfig
. Returns the parsed tsconfig as TsConfigJsonResolved
.
Type: string
Required path to the tsconfig file.
1import { parseTsconfig } from 'get-tsconfig'
2
3// Must pass in a path to an existing tsconfig.json file
4console.log(parseTsconfig('./path/to/tsconfig.custom.json'))
Given a tsconfig with compilerOptions.paths
defined, it returns a matcher function.
The matcher function accepts an import specifier (the path to resolve), checks it against compilerOptions.paths
, and returns an array of possible paths to check:
1function pathsMatcher(specifier: string): string[]
This function only returns possible paths and doesn't actually do any resolution. This helps increase compatibility wtih file/build systems which usually have their own resolvers.
1import { getTsconfig, createPathsMatcher } from 'get-tsconfig'
2
3const tsconfig = getTsconfig()
4const pathsMatcher = createPathsMatcher(tsconfig)
5
6function exampleResolver(request: string) {
7 if (pathsMatcher) {
8 const tryPaths = pathsMatcher(request)
9
10 // Check if paths in `tryPaths` exist
11 }
12}
tsconfig.json
?This package is a re-implementation of TypeScript's tsconfig.json
parser.
However, if you already have TypeScript as a dependency, you can simply use it's API:
1import {
2 sys as tsSys,
3 findConfigFile,
4 readConfigFile,
5 parseJsonConfigFileContent
6} from 'typescript'
7
8// Find tsconfig.json file
9const tsconfigPath = findConfigFile(process.cwd(), tsSys.fileExists, 'tsconfig.json')
10
11// Read tsconfig.json file
12const tsconfigFile = readConfigFile(tsconfigPath, tsSys.readFile)
13
14// Resolve extends
15const parsedTsconfig = parseJsonConfigFileContent(
16 tsconfigFile.config,
17 tsSys,
18 path.dirname(tsconfigPath)
19)
No vulnerabilities found.
No security vulnerabilities found.