Gathering detailed insights and metrics for get-tsconfig
Gathering detailed insights and metrics for get-tsconfig
Gathering detailed insights and metrics for get-tsconfig
Gathering detailed insights and metrics for get-tsconfig
get-tsconfig-compat
Portable version of get-tsconfig for earlier versions of node.js
@unts/get-tsconfig
Find and parse the tsconfig.json file from a directory path
@visulima/tsconfig
Find and/or parse the tsconfig.json file from a directory path.
eslint-plugin-i
A fork of `eslint-plugin-import` using `get-tsconfig` to replace `tsconfig-paths` and heavy `typescript` under the hood.
Lightweight tsconfig.json parser & paths resolver
npm install get-tsconfig
Typescript
Module System
Node Version
NPM Version
99.5
Supply Chain
98.9
Quality
82.6
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
1,132,724,616
Last Day
1,072,603
Last Week
18,881,683
Last Month
79,761,688
Last Year
702,638,111
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.10.1
Package Id
get-tsconfig@4.10.1
Unpacked Size
112.86 kB
Size
35.63 kB
File Count
7
NPM Version
10.5.0
Node Version
20.12.2
Published on
May 20, 2025
Cumulative downloads
Total Downloads
1
Find and parse tsconfig.json
files.
tsconfig.json
extends
tsconfig.json
7 kB
Minified + GzippedAlready a sponsor? Join the discussion in the Development repo!
1npm install get-tsconfig
For TypeScript related tooling to correctly parse tsconfig.json
file without depending on TypeScript.
Searches for a tsconfig file (defaults to tsconfig.json
) in the searchPath
and parses it. (If you already know the tsconfig path, use parseTsconfig
instead). 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 /** 4 * The path to the tsconfig.json file 5 */ 6 path: string 7 8 /** 9 * The resolved tsconfig.json file 10 */ 11 config: TsConfigJsonResolved 12}
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.
Type: Map<string, any>
Default: new Map()
Optional cache for fs operations.
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'))
14
15// Search for jsconfig.json - https://code.visualstudio.com/docs/languages/jsconfig
16console.log(getTsconfig('.', 'jsconfig.json'))
Parse the tsconfig file provided. Used internally by getTsconfig
. Returns the parsed tsconfig as TsConfigJsonResolved
.
Type: string
Required path to the tsconfig file.
Type: Map<string, any>
Default: new Map()
Optional cache for fs operations.
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.json
file, it returns a file-matcher function that determines whether it should apply to a file path.
1type FileMatcher = (filePath: string) => TsconfigResult['config'] | undefined
Type: TsconfigResult
Pass in the return value from getTsconfig
, or a TsconfigResult
object.
Type: boolean
By default, it uses is-fs-case-sensitive
to detect whether the file-system is case-sensitive.
Pass in true
to make it case-sensitive.
For example, if it's called with a tsconfig.json
file that has include
/exclude
/files
defined, the file-matcher will return the config for files that match include
/files
, and return undefined
for files that don't match or match exclude
.
1const tsconfig = getTsconfig()
2const fileMatcher = tsconfig && createFileMatcher(tsconfig)
3
4/*
5 * Returns tsconfig.json if it matches the file,
6 * undefined if not
7 */
8const configForFile = fileMatcher?.('/path/to/file.ts')
9const distCode = compileTypescript({
10 code: sourceCode,
11 tsconfig: configForFile
12})
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 6const 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.
Last Day
-3.5%
1,072,603
Compared to previous day
Last Week
-6.7%
18,881,683
Compared to previous week
Last Month
0.9%
79,761,688
Compared to previous month
Last Year
105.4%
702,638,111
Compared to previous year