get-tsconfig 4.13.6 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -98
- package/dist/index.d.mts +128 -22
- package/dist/index.mjs +7 -7
- package/package.json +10 -13
- package/skills/get-tsconfig/SKILL.md +146 -0
- package/dist/index.cjs +0 -7
- package/dist/index.d.cts +0 -2088
package/README.md
CHANGED
|
@@ -9,14 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
Find and parse `tsconfig.json` files.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
-
|
|
12
|
+
## Features
|
|
13
|
+
- Tiny! `9 kB` Minified + Gzipped
|
|
14
14
|
- Tested against TypeScript for correctness
|
|
15
|
-
- Supports comments & dangling commas in `tsconfig.json`
|
|
16
15
|
- Resolves [`extends`](https://www.typescriptlang.org/tsconfig/#extends)
|
|
17
16
|
- Fully typed `tsconfig.json`
|
|
18
17
|
- Validates and throws parsing errors
|
|
19
|
-
- Tiny! `7 kB` Minified + Gzipped
|
|
20
18
|
|
|
21
19
|
<br>
|
|
22
20
|
|
|
@@ -33,168 +31,198 @@ npm install get-tsconfig
|
|
|
33
31
|
```
|
|
34
32
|
|
|
35
33
|
## Why?
|
|
36
|
-
For TypeScript related tooling to correctly parse `tsconfig.json` file without depending on TypeScript.
|
|
37
34
|
|
|
38
|
-
|
|
35
|
+
TypeScript tooling (bundlers, linters, loaders, test runners) needs to read `tsconfig.json` to understand compiler options, path aliases, and file inclusion rules. But TypeScript's own config parser is buried inside the compiler and requires TypeScript as a dependency.
|
|
39
36
|
|
|
40
|
-
|
|
37
|
+
`get-tsconfig` provides the same functionality as a lightweight, standalone library — tested against TypeScript for correctness.
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Returns:
|
|
39
|
+
## Quick start
|
|
45
40
|
|
|
46
41
|
```ts
|
|
47
|
-
|
|
42
|
+
import { getTsconfig, isFileIncluded, resolvePathAlias } from 'get-tsconfig'
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
52
|
-
path: string
|
|
44
|
+
// Find and parse the nearest tsconfig.json
|
|
45
|
+
const tsconfig = getTsconfig()
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
// To resolve path aliases (compilerOptions.paths):
|
|
48
|
+
if (tsconfig) {
|
|
49
|
+
const resolved = resolvePathAlias(tsconfig, '@/utils/helper')
|
|
50
|
+
// → ['/project/src/utils/helper']
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// To check if a file belongs to this tsconfig:
|
|
54
|
+
if (tsconfig && isFileIncluded(tsconfig, '/project/src/index.ts')) {
|
|
55
|
+
// Use tsconfig.config.compilerOptions for transformation
|
|
58
56
|
}
|
|
59
57
|
```
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
Type: `string`
|
|
59
|
+
## Finding & reading tsconfig
|
|
63
60
|
|
|
64
|
-
|
|
61
|
+
These functions find, read, and parse tsconfig files from the filesystem. All return a `TsconfigResult`:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
type TsconfigResult<Config = TsconfigJsonResolved> = {
|
|
65
|
+
path: string
|
|
66
|
+
config: Config
|
|
67
|
+
sources: string[]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
65
70
|
|
|
66
|
-
|
|
71
|
+
- **path**: absolute path to the tsconfig file
|
|
72
|
+
- **config**: the fully resolved config (extends merged, options normalized)
|
|
73
|
+
- **sources**: paths of all tsconfig files that contributed to the resolved config via [`extends`](https://www.typescriptlang.org/tsconfig/#extends). When there are no `extends`, this is just `[path]`. Since `extends` can be an array, the order does not imply a linear chain.
|
|
67
74
|
|
|
68
|
-
|
|
75
|
+
### getTsconfig(searchPath?, options?)
|
|
76
|
+
|
|
77
|
+
Searches for a tsconfig file and parses it. If you already know the path, use [`readTsconfig`](#readtsconfigtsconfigpath-options) instead. Returns `undefined` if not found.
|
|
78
|
+
|
|
79
|
+
#### searchPath
|
|
69
80
|
Type: `string`
|
|
70
81
|
|
|
71
|
-
Default: `
|
|
82
|
+
Default: `process.cwd()`
|
|
72
83
|
|
|
73
|
-
|
|
84
|
+
Path to a file or directory. The directory tree is searched up for `tsconfig.json`.
|
|
74
85
|
|
|
75
|
-
####
|
|
76
|
-
Type: `
|
|
86
|
+
#### options
|
|
87
|
+
Type: `GetTsconfigOptions`
|
|
77
88
|
|
|
78
|
-
|
|
89
|
+
```ts
|
|
90
|
+
type GetTsconfigOptions = {
|
|
91
|
+
configName?: string // default: 'tsconfig.json'
|
|
92
|
+
cache?: Map<string, unknown>
|
|
93
|
+
includes?: boolean // default: false
|
|
94
|
+
}
|
|
95
|
+
```
|
|
79
96
|
|
|
80
|
-
|
|
97
|
+
- **configName**: file name to search for (e.g. `'jsconfig.json'`)
|
|
98
|
+
- **cache**: snapshot cache for fs operations. Reusing after filesystem changes can return stale results.
|
|
99
|
+
- **includes**: when `true`, validates the file is a root file (matched by `include`/`files` globs, not excluded) before accepting the tsconfig. Matches VS Code's Language Server behavior. Default matches `tsc` CLI behavior (nearest tsconfig). Note: this checks glob matching only — a file can still be part of a TypeScript program via transitive imports even if not matched by `include`.
|
|
81
100
|
|
|
82
101
|
#### Example
|
|
83
102
|
|
|
84
103
|
```ts
|
|
85
104
|
import { getTsconfig } from 'get-tsconfig'
|
|
86
105
|
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// Find tsconfig.json from a TypeScript file path
|
|
91
|
-
console.log(getTsconfig('./path/to/index.ts'))
|
|
106
|
+
// Find from current directory
|
|
107
|
+
getTsconfig()
|
|
92
108
|
|
|
93
|
-
// Find
|
|
94
|
-
|
|
109
|
+
// Find from a file path
|
|
110
|
+
getTsconfig('./src/index.ts')
|
|
95
111
|
|
|
96
|
-
//
|
|
97
|
-
|
|
112
|
+
// Search for jsconfig.json
|
|
113
|
+
getTsconfig('.', { configName: 'jsconfig.json' })
|
|
98
114
|
|
|
99
|
-
//
|
|
100
|
-
|
|
115
|
+
// Language Server behavior — validate the file is included
|
|
116
|
+
getTsconfig('./src/index.ts', { includes: true })
|
|
101
117
|
```
|
|
102
118
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
### parseTsconfig(tsconfigPath, cache?)
|
|
119
|
+
### findTsconfig(searchPath?, options?)
|
|
106
120
|
|
|
107
|
-
|
|
121
|
+
Like `getTsconfig`, but returns only the path (`string | undefined`) without parsing. Same options.
|
|
108
122
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
Required path to the tsconfig file.
|
|
123
|
+
```ts
|
|
124
|
+
import { findTsconfig } from 'get-tsconfig'
|
|
113
125
|
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
findTsconfig() // → '/project/tsconfig.json'
|
|
127
|
+
```
|
|
116
128
|
|
|
117
|
-
|
|
129
|
+
### readTsconfig(tsconfigPath, options?)
|
|
118
130
|
|
|
119
|
-
|
|
131
|
+
Reads and resolves a tsconfig at a known path. Used internally by `getTsconfig`.
|
|
120
132
|
|
|
121
|
-
|
|
133
|
+
```ts
|
|
134
|
+
type ReadTsconfigOptions = {
|
|
135
|
+
cache?: Map<string, unknown>
|
|
136
|
+
}
|
|
137
|
+
```
|
|
122
138
|
|
|
123
139
|
```ts
|
|
124
|
-
import {
|
|
140
|
+
import { readTsconfig } from 'get-tsconfig'
|
|
125
141
|
|
|
126
|
-
|
|
127
|
-
console.log(parseTsconfig('./path/to/tsconfig.custom.json'))
|
|
142
|
+
const { path, config } = readTsconfig('./tsconfig.json')
|
|
128
143
|
```
|
|
129
144
|
|
|
130
|
-
|
|
145
|
+
## Tsconfig `extends`
|
|
146
|
+
|
|
147
|
+
`readTsconfig` and `getTsconfig` fully resolve the [`extends`](https://www.typescriptlang.org/tsconfig/#extends) chain and return a flattened config. These two functions expose the chain for use cases like watch mode and config auditing.
|
|
131
148
|
|
|
132
|
-
###
|
|
149
|
+
### getExtendsChain(tsconfigPath, options?)
|
|
133
150
|
|
|
134
|
-
|
|
151
|
+
Collects the full extends chain. Returns an array of `TsconfigResult<TsconfigJson>` entries — each containing the raw (unmerged) config with `extends` resolved to absolute paths. (`TsconfigJson` is the raw tsconfig.json shape, including the `extends` field.)
|
|
152
|
+
|
|
153
|
+
`chain[0]` is the root. Ancestors follow in resolution order.
|
|
135
154
|
|
|
136
155
|
```ts
|
|
137
|
-
type
|
|
156
|
+
type GetExtendsChainOptions = {
|
|
157
|
+
cache?: Map<string, unknown>
|
|
158
|
+
}
|
|
138
159
|
```
|
|
139
160
|
|
|
140
|
-
|
|
141
|
-
|
|
161
|
+
```ts
|
|
162
|
+
import { getExtendsChain } from 'get-tsconfig'
|
|
142
163
|
|
|
143
|
-
|
|
164
|
+
const chain = getExtendsChain('./tsconfig.json')
|
|
165
|
+
// [
|
|
166
|
+
// { path: '/project/tsconfig.json', config: { extends: '/project/base.json', ... } },
|
|
167
|
+
// { path: '/project/base.json', config: { ... } },
|
|
168
|
+
// ]
|
|
144
169
|
|
|
145
|
-
|
|
146
|
-
|
|
170
|
+
// Watch all files in the extends chain
|
|
171
|
+
const filesToWatch = chain.map(entry => entry.path)
|
|
172
|
+
```
|
|
147
173
|
|
|
148
|
-
|
|
174
|
+
### resolveExtendsChain(chain)
|
|
149
175
|
|
|
150
|
-
|
|
176
|
+
Merges a collected extends chain into a resolved tsconfig. Pure function — no filesystem access.
|
|
151
177
|
|
|
152
|
-
|
|
178
|
+
```ts
|
|
179
|
+
import { getExtendsChain, resolveExtendsChain } from 'get-tsconfig'
|
|
153
180
|
|
|
154
|
-
|
|
181
|
+
const chain = getExtendsChain('./tsconfig.json')
|
|
155
182
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const configForFile = fileMatcher?.('/path/to/file.ts')
|
|
165
|
-
const distCode = compileTypescript({
|
|
166
|
-
code: sourceCode,
|
|
167
|
-
tsconfig: configForFile
|
|
168
|
-
})
|
|
183
|
+
// Modify before merging
|
|
184
|
+
chain[0].config.compilerOptions = {
|
|
185
|
+
...chain[0].config.compilerOptions,
|
|
186
|
+
sourceMap: true
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const result = resolveExtendsChain(chain)
|
|
190
|
+
// TsconfigResult { path, config, sources }
|
|
169
191
|
```
|
|
170
192
|
|
|
171
|
-
|
|
193
|
+
## Working with a tsconfig
|
|
194
|
+
|
|
195
|
+
These functions take a parsed `TsconfigResult` (from `getTsconfig` or `readTsconfig`) and answer questions about it. They cache compiled state per tsconfig object — do not mutate the tsconfig after the first call.
|
|
196
|
+
|
|
197
|
+
### isFileIncluded(tsconfig, filePath)
|
|
172
198
|
|
|
173
|
-
|
|
199
|
+
Checks whether an absolute file path matches a tsconfig's `files`, `include`, and `exclude` globs — i.e., whether it's a **root file**. Case sensitivity is auto-detected from the filesystem. Non-absolute paths return `false`.
|
|
174
200
|
|
|
175
|
-
|
|
201
|
+
> [!NOTE]
|
|
202
|
+
> This checks glob matching only, not transitive imports. A file outside `include` can still be part of the TypeScript program if it's imported by a root file. `exclude` only filters the initial glob matching — it doesn't prevent transitively imported files from being compiled.
|
|
176
203
|
|
|
177
|
-
The matcher function accepts an [import specifier (the path to resolve)](https://nodejs.org/api/esm.html#terminology), checks it against `compilerOptions.paths`, and returns an array of possible paths to check:
|
|
178
204
|
```ts
|
|
179
|
-
|
|
205
|
+
import { getTsconfig, isFileIncluded } from 'get-tsconfig'
|
|
206
|
+
|
|
207
|
+
const tsconfig = getTsconfig()
|
|
208
|
+
|
|
209
|
+
if (tsconfig && isFileIncluded(tsconfig, '/path/to/file.ts')) {
|
|
210
|
+
// file is a root file of this tsconfig
|
|
211
|
+
}
|
|
180
212
|
```
|
|
181
213
|
|
|
182
|
-
|
|
214
|
+
### resolvePathAlias(tsconfig, specifier)
|
|
183
215
|
|
|
184
|
-
|
|
216
|
+
Resolves an [import specifier](https://nodejs.org/api/esm.html#terminology) against [`compilerOptions.paths`](https://www.typescriptlang.org/tsconfig#paths). Returns an array of possible file paths, or an empty array if no match. Does not perform actual file resolution.
|
|
185
217
|
|
|
186
218
|
```ts
|
|
187
|
-
import { getTsconfig,
|
|
219
|
+
import { getTsconfig, resolvePathAlias } from 'get-tsconfig'
|
|
188
220
|
|
|
189
221
|
const tsconfig = getTsconfig()
|
|
190
|
-
const pathsMatcher = createPathsMatcher(tsconfig)
|
|
191
|
-
|
|
192
|
-
const exampleResolver = (request: string) => {
|
|
193
|
-
if (pathsMatcher) {
|
|
194
|
-
const tryPaths = pathsMatcher(request)
|
|
195
222
|
|
|
196
|
-
|
|
197
|
-
|
|
223
|
+
const tryPaths = tsconfig && resolvePathAlias(tsconfig, '@/utils/helper')
|
|
224
|
+
if (tryPaths?.length) {
|
|
225
|
+
// Check if paths in tryPaths exist
|
|
198
226
|
}
|
|
199
227
|
```
|
|
200
228
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2044,45 +2044,151 @@ type TsConfigJson = {
|
|
|
2044
2044
|
references?: TsConfigJson.References[];
|
|
2045
2045
|
};
|
|
2046
2046
|
|
|
2047
|
-
type
|
|
2048
|
-
type
|
|
2047
|
+
type TsconfigJsonResolved = Except<TsConfigJson, 'extends'>;
|
|
2048
|
+
type TsconfigResult<Config = TsconfigJsonResolved> = {
|
|
2049
2049
|
/**
|
|
2050
|
-
* The
|
|
2050
|
+
* The tsconfig.json content. When using the default type parameter,
|
|
2051
|
+
* this is the fully resolved config (extends merged, options normalized).
|
|
2052
|
+
*/
|
|
2053
|
+
config: Config;
|
|
2054
|
+
/**
|
|
2055
|
+
* Absolute path to the tsconfig.json file
|
|
2051
2056
|
*/
|
|
2052
2057
|
path: string;
|
|
2053
2058
|
/**
|
|
2054
|
-
*
|
|
2059
|
+
* Paths of all tsconfig files that contributed to this config (via `extends`).
|
|
2060
|
+
* `sources[0]` is the root tsconfig (same as `.path`), followed by extended
|
|
2061
|
+
* configs in resolution order.
|
|
2062
|
+
*
|
|
2063
|
+
* Only present on resolved results (not on intermediate chain entries).
|
|
2055
2064
|
*/
|
|
2056
|
-
|
|
2065
|
+
sources?: string[];
|
|
2066
|
+
};
|
|
2067
|
+
type TsconfigCache<value = any> = Map<string, value>;
|
|
2068
|
+
type TsconfigSearchOptions = {
|
|
2069
|
+
configName?: string;
|
|
2070
|
+
cache?: TsconfigCache;
|
|
2071
|
+
includes?: boolean;
|
|
2072
|
+
};
|
|
2073
|
+
type GetTsconfigOptions = TsconfigSearchOptions;
|
|
2074
|
+
type FindTsconfigOptions = TsconfigSearchOptions;
|
|
2075
|
+
type TsconfigCacheOptions = {
|
|
2076
|
+
cache?: TsconfigCache;
|
|
2057
2077
|
};
|
|
2058
|
-
type
|
|
2078
|
+
type ReadTsconfigOptions = TsconfigCacheOptions;
|
|
2079
|
+
type GetExtendsChainOptions = TsconfigCacheOptions;
|
|
2059
2080
|
|
|
2060
2081
|
/**
|
|
2061
|
-
*
|
|
2082
|
+
* Searches for a tsconfig file by walking up the directory tree.
|
|
2083
|
+
*
|
|
2084
|
+
* @param searchPath Path to a source file or directory to search from (default: `process.cwd()`).
|
|
2085
|
+
* @param options Optional search configuration.
|
|
2086
|
+
* @param options.configName Config file name (default: `tsconfig.json`).
|
|
2087
|
+
* @param options.cache Cache for previous results (default: new `Map()`).
|
|
2088
|
+
* @param options.includes When true, validates that the tsconfig applies to the
|
|
2089
|
+
* `searchPath` file via `include`/`exclude`/`files`. See {@link getTsconfig}
|
|
2090
|
+
* for details. Default: `false`.
|
|
2091
|
+
* @returns The path to the found tsconfig file, or `undefined` if not found.
|
|
2092
|
+
*/
|
|
2093
|
+
declare const findTsconfig: (searchPath?: string, options?: FindTsconfigOptions) => string | undefined;
|
|
2094
|
+
/**
|
|
2095
|
+
* Finds and reads a tsconfig file by walking up the directory tree.
|
|
2096
|
+
*
|
|
2097
|
+
* By default, returns the nearest tsconfig found (matching `tsc` CLI behavior).
|
|
2062
2098
|
*
|
|
2063
|
-
*
|
|
2064
|
-
*
|
|
2065
|
-
*
|
|
2066
|
-
*
|
|
2099
|
+
* When `includes` is true and `searchPath` is a file path, validates
|
|
2100
|
+
* that the found tsconfig applies to the file (via `files`, `include`, and
|
|
2101
|
+
* `exclude`). If the file isn't matched, continues searching parent directories.
|
|
2102
|
+
* This matches VS Code's TypeScript Language Server behavior.
|
|
2103
|
+
*
|
|
2104
|
+
* Reference:
|
|
2105
|
+
* - `tsc` CLI uses `findConfigFile()` which returns the nearest tsconfig without validation:
|
|
2106
|
+
* https://github.com/microsoft/TypeScript/blob/b19a9da2a3b8/src/compiler/program.ts#L328
|
|
2107
|
+
* - Language Server uses `isMatchedByConfig()` to verify the file belongs to the project:
|
|
2108
|
+
* https://github.com/microsoft/TypeScript/blob/b19a9da2a3b8/src/server/editorServices.ts#L4486
|
|
2109
|
+
*
|
|
2110
|
+
* @param searchPath Path to a source file or directory to search from (default: `process.cwd()`).
|
|
2111
|
+
* @param options Optional search configuration.
|
|
2112
|
+
* @param options.configName Config file name (default: `tsconfig.json`).
|
|
2113
|
+
* @param options.cache Cache for previous results (default: new `Map()`).
|
|
2114
|
+
* @param options.includes When true, validates that the tsconfig applies to the
|
|
2115
|
+
* `searchPath` file via `include`/`exclude`/`files`. Default: `false`.
|
|
2116
|
+
* @returns The tsconfig file path and parsed contents, or `undefined` if not found.
|
|
2067
2117
|
*/
|
|
2068
|
-
declare const getTsconfig: (searchPath?: string,
|
|
2118
|
+
declare const getTsconfig: (searchPath?: string, options?: GetTsconfigOptions) => TsconfigResult | undefined;
|
|
2069
2119
|
|
|
2070
2120
|
/**
|
|
2071
|
-
*
|
|
2121
|
+
* Collects the extends chain for a tsconfig file.
|
|
2122
|
+
*
|
|
2123
|
+
* Walks the filesystem to discover all configs in the extends chain,
|
|
2124
|
+
* returning them as a flat array with `extends` resolved to absolute paths.
|
|
2125
|
+
*
|
|
2126
|
+
* @param tsconfigPath - Path to the tsconfig file.
|
|
2127
|
+
* @param options - Optional read configuration.
|
|
2128
|
+
* @param options.cache - Cache for filesystem reads (default: new `Map()`).
|
|
2129
|
+
* @returns Array of `{ path, config }` entries. `chain[0]` is the root config.
|
|
2130
|
+
* Ordered root-first, deepest ancestor last.
|
|
2131
|
+
*/
|
|
2132
|
+
declare const getExtendsChain: (tsconfigPath: string, options?: GetExtendsChainOptions) => TsconfigResult<TsConfigJson>[];
|
|
2133
|
+
/**
|
|
2134
|
+
* Reads and resolves a tsconfig file at a given path
|
|
2072
2135
|
*
|
|
2073
2136
|
* @param tsconfigPath - Path to the tsconfig file.
|
|
2074
|
-
* @param
|
|
2075
|
-
* @
|
|
2137
|
+
* @param options - Optional read configuration.
|
|
2138
|
+
* @param options.cache - Cache for filesystem reads and resolution results
|
|
2139
|
+
* (default: new `Map()`).
|
|
2140
|
+
* @returns The resolved absolute path and config. The path is the same one used
|
|
2141
|
+
* internally for extends resolution.
|
|
2076
2142
|
*/
|
|
2077
|
-
declare const
|
|
2143
|
+
declare const readTsconfig: (tsconfigPath: string, options?: ReadTsconfigOptions) => TsconfigResult;
|
|
2078
2144
|
|
|
2079
2145
|
/**
|
|
2080
|
-
*
|
|
2081
|
-
*
|
|
2146
|
+
* Resolves a collected extends chain into a merged tsconfig.
|
|
2147
|
+
*
|
|
2148
|
+
* Pure function — no filesystem access. Expects the output of
|
|
2149
|
+
* `getExtendsChain` or an equivalent acyclic, root-first chain
|
|
2150
|
+
* with `extends` resolved to absolute paths.
|
|
2151
|
+
*
|
|
2152
|
+
* @param chain - Array of `{ path, config }` entries. `chain[0]` is the
|
|
2153
|
+
* root config. Must be acyclic — cyclic extends will cause infinite recursion.
|
|
2154
|
+
* @returns The resolved tsconfig with path and fully merged config.
|
|
2082
2155
|
*/
|
|
2083
|
-
declare const
|
|
2156
|
+
declare const resolveExtendsChain: (chain: TsconfigResult<TsConfigJson>[]) => TsconfigResult;
|
|
2084
2157
|
|
|
2085
|
-
|
|
2086
|
-
|
|
2158
|
+
/**
|
|
2159
|
+
* Resolves a specifier against a tsconfig's `compilerOptions.paths` mappings.
|
|
2160
|
+
*
|
|
2161
|
+
* Returns an array of possible file paths to check. Returns an empty
|
|
2162
|
+
* array when no `paths` are configured or no pattern matches.
|
|
2163
|
+
* Does not perform actual file resolution — compatible with any
|
|
2164
|
+
* file/build system resolver.
|
|
2165
|
+
*
|
|
2166
|
+
* Results are cached per tsconfig object. The tsconfig must not be
|
|
2167
|
+
* mutated after the first call.
|
|
2168
|
+
*
|
|
2169
|
+
* @param tsconfig - The resolved tsconfig to resolve against (treat as immutable).
|
|
2170
|
+
* @param specifier - The import specifier to resolve.
|
|
2171
|
+
* @returns Array of possible file paths, or empty array if no match.
|
|
2172
|
+
*/
|
|
2173
|
+
declare const resolvePathAlias: (tsconfig: TsconfigResult, specifier: string) => string[];
|
|
2174
|
+
|
|
2175
|
+
/**
|
|
2176
|
+
* Checks whether a file is included by a tsconfig's `files`, `include`,
|
|
2177
|
+
* and `exclude` settings.
|
|
2178
|
+
*
|
|
2179
|
+
* Case sensitivity is auto-detected from the filesystem, matching
|
|
2180
|
+
* TypeScript's behavior.
|
|
2181
|
+
*
|
|
2182
|
+
* The `filePath` must be absolute. Non-absolute paths return `false`.
|
|
2183
|
+
*
|
|
2184
|
+
* Compiled patterns are cached per tsconfig object. The tsconfig must
|
|
2185
|
+
* not be mutated after the first call — mutation will not invalidate
|
|
2186
|
+
* the cache and may return stale results.
|
|
2187
|
+
*
|
|
2188
|
+
* @param tsconfig - The resolved tsconfig to check against (treat as immutable).
|
|
2189
|
+
* @param filePath - Absolute path to the file.
|
|
2190
|
+
* @returns `true` if the file is included, `false` otherwise.
|
|
2191
|
+
*/
|
|
2192
|
+
declare const isFileIncluded: (tsconfig: TsconfigResult, filePath: string) => boolean;
|
|
2087
2193
|
|
|
2088
|
-
export { type
|
|
2194
|
+
export { type FindTsconfigOptions, type GetExtendsChainOptions, type GetTsconfigOptions, type ReadTsconfigOptions, type TsconfigCache, TsConfigJson as TsconfigJson, type TsconfigJsonResolved, type TsconfigResult, findTsconfig, getExtendsChain, getTsconfig, isFileIncluded, readTsconfig, resolveExtendsChain, resolvePathAlias };
|