@bemoje/monorepo 2.0.0 → 3.0.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 +80 -35
- package/lib/index.cjs +578 -2257
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +410 -2546
- package/lib/index.d.ts +410 -2546
- package/lib/index.js +557 -2250
- package/lib/index.js.map +1 -0
- package/package.json +7 -7
package/lib/index.d.cts
CHANGED
|
@@ -1,2193 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MultiSet, DefaultMap } from 'mnemonist';
|
|
1
|
+
import * as es_toolkit from 'es-toolkit';
|
|
3
2
|
import * as typescript from 'typescript';
|
|
4
|
-
import { CompilerOptions } from 'typescript';
|
|
5
|
-
import { Results } from 'depcheck';
|
|
6
|
-
import { Stats } from 'fs';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
|
-
|
|
10
|
-
* View methods are redirected to the wrapped object which acts as
|
|
11
|
-
* a surrogate 'this'.
|
|
12
|
-
*
|
|
13
|
-
* To create a method that redirects to 'target', @see {@link defineProxifiedPrototypeProperty}
|
|
14
|
-
*/
|
|
15
|
-
interface IView<T extends object> {
|
|
16
|
-
readonly target: T;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
Returns a boolean for whether the given type is `any`.
|
|
21
|
-
|
|
22
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
23
|
-
|
|
24
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
25
|
-
|
|
26
|
-
@example
|
|
27
|
-
```
|
|
28
|
-
import type {IsAny} from 'type-fest';
|
|
29
|
-
|
|
30
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
31
|
-
const anyObject: any = {a: 1, b: 2};
|
|
32
|
-
|
|
33
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
34
|
-
return object[key];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const typedA = get(typedObject, 'a');
|
|
38
|
-
//=> 1
|
|
39
|
-
|
|
40
|
-
const anyA = get(anyObject, 'a');
|
|
41
|
-
//=> any
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
@category Type Guard
|
|
45
|
-
@category Utilities
|
|
46
|
-
*/
|
|
47
|
-
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
Returns a boolean for whether the given key is an optional key of type.
|
|
51
|
-
|
|
52
|
-
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
53
|
-
|
|
54
|
-
@example
|
|
55
|
-
```
|
|
56
|
-
import type {IsOptionalKeyOf} from 'type-fest';
|
|
57
|
-
|
|
58
|
-
type User = {
|
|
59
|
-
name: string;
|
|
60
|
-
surname: string;
|
|
61
|
-
|
|
62
|
-
luckyNumber?: number;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
type Admin = {
|
|
66
|
-
name: string;
|
|
67
|
-
surname?: string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
71
|
-
//=> true
|
|
72
|
-
|
|
73
|
-
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
74
|
-
//=> false
|
|
75
|
-
|
|
76
|
-
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
77
|
-
//=> boolean
|
|
78
|
-
|
|
79
|
-
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
80
|
-
//=> false
|
|
81
|
-
|
|
82
|
-
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
83
|
-
//=> boolean
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
@category Type Guard
|
|
87
|
-
@category Utilities
|
|
88
|
-
*/
|
|
89
|
-
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> =
|
|
90
|
-
IsAny<Type | Key> extends true ? never
|
|
91
|
-
: Key extends keyof Type
|
|
92
|
-
? Type extends Record<Key, Type[Key]>
|
|
93
|
-
? false
|
|
94
|
-
: true
|
|
95
|
-
: false;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
Extract all optional keys from the given type.
|
|
99
|
-
|
|
100
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
101
|
-
|
|
102
|
-
@example
|
|
103
|
-
```
|
|
104
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
105
|
-
|
|
106
|
-
type User = {
|
|
107
|
-
name: string;
|
|
108
|
-
surname: string;
|
|
109
|
-
|
|
110
|
-
luckyNumber?: number;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
114
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
115
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const update1: UpdateOperation<User> = {
|
|
119
|
-
name: 'Alice',
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const update2: UpdateOperation<User> = {
|
|
123
|
-
name: 'Bob',
|
|
124
|
-
luckyNumber: REMOVE_FIELD,
|
|
125
|
-
};
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
@category Utilities
|
|
129
|
-
*/
|
|
130
|
-
type OptionalKeysOf<Type extends object> =
|
|
131
|
-
Type extends unknown // For distributing `Type`
|
|
132
|
-
? (keyof {[Key in keyof Type as
|
|
133
|
-
IsOptionalKeyOf<Type, Key> extends false
|
|
134
|
-
? never
|
|
135
|
-
: Key
|
|
136
|
-
]: never
|
|
137
|
-
}) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
138
|
-
: never; // Should never happen
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
Extract all required keys from the given type.
|
|
142
|
-
|
|
143
|
-
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
144
|
-
|
|
145
|
-
@example
|
|
146
|
-
```
|
|
147
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
148
|
-
|
|
149
|
-
declare function createValidation<
|
|
150
|
-
Entity extends object,
|
|
151
|
-
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
152
|
-
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
153
|
-
|
|
154
|
-
type User = {
|
|
155
|
-
name: string;
|
|
156
|
-
surname: string;
|
|
157
|
-
luckyNumber?: number;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
161
|
-
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
162
|
-
|
|
163
|
-
// @ts-expect-error
|
|
164
|
-
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
165
|
-
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
@category Utilities
|
|
169
|
-
*/
|
|
170
|
-
type RequiredKeysOf<Type extends object> =
|
|
171
|
-
Type extends unknown // For distributing `Type`
|
|
172
|
-
? Exclude<keyof Type, OptionalKeysOf<Type>>
|
|
173
|
-
: never; // Should never happen
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
Returns a boolean for whether the given type is `never`.
|
|
177
|
-
|
|
178
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
179
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
180
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
181
|
-
|
|
182
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
183
|
-
|
|
184
|
-
@example
|
|
185
|
-
```
|
|
186
|
-
import type {IsNever, And} from 'type-fest';
|
|
187
|
-
|
|
188
|
-
type A = IsNever<never>;
|
|
189
|
-
//=> true
|
|
190
|
-
|
|
191
|
-
type B = IsNever<any>;
|
|
192
|
-
//=> false
|
|
193
|
-
|
|
194
|
-
type C = IsNever<unknown>;
|
|
195
|
-
//=> false
|
|
196
|
-
|
|
197
|
-
type D = IsNever<never[]>;
|
|
198
|
-
//=> false
|
|
199
|
-
|
|
200
|
-
type E = IsNever<object>;
|
|
201
|
-
//=> false
|
|
202
|
-
|
|
203
|
-
type F = IsNever<string>;
|
|
204
|
-
//=> false
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
@example
|
|
208
|
-
```
|
|
209
|
-
import type {IsNever} from 'type-fest';
|
|
210
|
-
|
|
211
|
-
type IsTrue<T> = T extends true ? true : false;
|
|
212
|
-
|
|
213
|
-
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
214
|
-
type A = IsTrue<never>;
|
|
215
|
-
//=> never
|
|
216
|
-
|
|
217
|
-
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
218
|
-
type IsTrueFixed<T> =
|
|
219
|
-
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
220
|
-
|
|
221
|
-
type B = IsTrueFixed<never>;
|
|
222
|
-
//=> false
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
@category Type Guard
|
|
226
|
-
@category Utilities
|
|
227
|
-
*/
|
|
228
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
232
|
-
|
|
233
|
-
Use-cases:
|
|
234
|
-
- You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
|
|
235
|
-
|
|
236
|
-
Note:
|
|
237
|
-
- Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
|
|
238
|
-
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
239
|
-
|
|
240
|
-
@example
|
|
241
|
-
```
|
|
242
|
-
import type {If} from 'type-fest';
|
|
243
|
-
|
|
244
|
-
type A = If<true, 'yes', 'no'>;
|
|
245
|
-
//=> 'yes'
|
|
246
|
-
|
|
247
|
-
type B = If<false, 'yes', 'no'>;
|
|
248
|
-
//=> 'no'
|
|
249
|
-
|
|
250
|
-
type C = If<boolean, 'yes', 'no'>;
|
|
251
|
-
//=> 'yes' | 'no'
|
|
252
|
-
|
|
253
|
-
type D = If<any, 'yes', 'no'>;
|
|
254
|
-
//=> 'yes' | 'no'
|
|
255
|
-
|
|
256
|
-
type E = If<never, 'yes', 'no'>;
|
|
257
|
-
//=> 'no'
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
@example
|
|
261
|
-
```
|
|
262
|
-
import type {If, IsAny, IsNever} from 'type-fest';
|
|
263
|
-
|
|
264
|
-
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
265
|
-
//=> 'not any'
|
|
266
|
-
|
|
267
|
-
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
268
|
-
//=> 'is never'
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
@example
|
|
272
|
-
```
|
|
273
|
-
import type {If, IsEqual} from 'type-fest';
|
|
274
|
-
|
|
275
|
-
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
276
|
-
|
|
277
|
-
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
278
|
-
//=> 'equal'
|
|
279
|
-
|
|
280
|
-
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
281
|
-
//=> 'not equal'
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
|
|
285
|
-
|
|
286
|
-
@example
|
|
287
|
-
```
|
|
288
|
-
import type {If, IsEqual, StringRepeat} from 'type-fest';
|
|
289
|
-
|
|
290
|
-
type HundredZeroes = StringRepeat<'0', 100>;
|
|
291
|
-
|
|
292
|
-
// The following implementation is not tail recursive
|
|
293
|
-
type Includes<S extends string, Char extends string> =
|
|
294
|
-
S extends `${infer First}${infer Rest}`
|
|
295
|
-
? If<IsEqual<First, Char>,
|
|
296
|
-
'found',
|
|
297
|
-
Includes<Rest, Char>>
|
|
298
|
-
: 'not found';
|
|
299
|
-
|
|
300
|
-
// Hence, instantiations with long strings will fail
|
|
301
|
-
// @ts-expect-error
|
|
302
|
-
type Fails = Includes<HundredZeroes, '1'>;
|
|
303
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
304
|
-
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
305
|
-
|
|
306
|
-
// However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
|
|
307
|
-
type IncludesWithoutIf<S extends string, Char extends string> =
|
|
308
|
-
S extends `${infer First}${infer Rest}`
|
|
309
|
-
? IsEqual<First, Char> extends true
|
|
310
|
-
? 'found'
|
|
311
|
-
: IncludesWithoutIf<Rest, Char>
|
|
312
|
-
: 'not found';
|
|
313
|
-
|
|
314
|
-
// Now, instantiations with long strings will work
|
|
315
|
-
type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
316
|
-
//=> 'not found'
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
@category Type Guard
|
|
320
|
-
@category Utilities
|
|
321
|
-
*/
|
|
322
|
-
type If<Type extends boolean, IfBranch, ElseBranch> =
|
|
323
|
-
IsNever<Type> extends true
|
|
324
|
-
? ElseBranch
|
|
325
|
-
: Type extends true
|
|
326
|
-
? IfBranch
|
|
327
|
-
: ElseBranch;
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
331
|
-
|
|
332
|
-
@example
|
|
333
|
-
```
|
|
334
|
-
import type {Simplify} from 'type-fest';
|
|
335
|
-
|
|
336
|
-
type PositionProps = {
|
|
337
|
-
top: number;
|
|
338
|
-
left: number;
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
type SizeProps = {
|
|
342
|
-
width: number;
|
|
343
|
-
height: number;
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
347
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
351
|
-
|
|
352
|
-
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
353
|
-
|
|
354
|
-
@example
|
|
355
|
-
```
|
|
356
|
-
import type {Simplify} from 'type-fest';
|
|
357
|
-
|
|
358
|
-
interface SomeInterface {
|
|
359
|
-
foo: number;
|
|
360
|
-
bar?: string;
|
|
361
|
-
baz: number | undefined;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
type SomeType = {
|
|
365
|
-
foo: number;
|
|
366
|
-
bar?: string;
|
|
367
|
-
baz: number | undefined;
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
371
|
-
const someType: SomeType = literal;
|
|
372
|
-
const someInterface: SomeInterface = literal;
|
|
373
|
-
|
|
374
|
-
declare function fn(object: Record<string, unknown>): void;
|
|
375
|
-
|
|
376
|
-
fn(literal); // Good: literal object type is sealed
|
|
377
|
-
fn(someType); // Good: type is sealed
|
|
378
|
-
// @ts-expect-error
|
|
379
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
380
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
384
|
-
@see {@link SimplifyDeep}
|
|
385
|
-
@category Object
|
|
386
|
-
*/
|
|
387
|
-
type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
Returns a boolean for whether the two given types are equal.
|
|
391
|
-
|
|
392
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
393
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
394
|
-
|
|
395
|
-
Use-cases:
|
|
396
|
-
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
397
|
-
|
|
398
|
-
@example
|
|
399
|
-
```
|
|
400
|
-
import type {IsEqual} from 'type-fest';
|
|
401
|
-
|
|
402
|
-
// This type returns a boolean for whether the given array includes the given item.
|
|
403
|
-
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
404
|
-
type Includes<Value extends readonly any[], Item> =
|
|
405
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
406
|
-
? IsEqual<Value[0], Item> extends true
|
|
407
|
-
? true
|
|
408
|
-
: Includes<rest, Item>
|
|
409
|
-
: false;
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
@category Type Guard
|
|
413
|
-
@category Utilities
|
|
414
|
-
*/
|
|
415
|
-
type IsEqual<A, B> =
|
|
416
|
-
[A] extends [B]
|
|
417
|
-
? [B] extends [A]
|
|
418
|
-
? _IsEqual<A, B>
|
|
419
|
-
: false
|
|
420
|
-
: false;
|
|
421
|
-
|
|
422
|
-
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
423
|
-
type _IsEqual<A, B> =
|
|
424
|
-
(<G>() => G extends A & G | G ? 1 : 2) extends
|
|
425
|
-
(<G>() => G extends B & G | G ? 1 : 2)
|
|
426
|
-
? true
|
|
427
|
-
: false;
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
431
|
-
|
|
432
|
-
This is the counterpart of `PickIndexSignature`.
|
|
433
|
-
|
|
434
|
-
Use-cases:
|
|
435
|
-
- Remove overly permissive signatures from third-party types.
|
|
436
|
-
|
|
437
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
438
|
-
|
|
439
|
-
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
440
|
-
|
|
441
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
442
|
-
|
|
443
|
-
```
|
|
444
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
445
|
-
|
|
446
|
-
// @ts-expect-error
|
|
447
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
448
|
-
// TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
452
|
-
|
|
453
|
-
```
|
|
454
|
-
type Indexed = {} extends Record<string, unknown>
|
|
455
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
456
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
457
|
-
|
|
458
|
-
type IndexedResult = Indexed;
|
|
459
|
-
//=> '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
460
|
-
|
|
461
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
462
|
-
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
463
|
-
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
464
|
-
|
|
465
|
-
type KeyedResult = Keyed;
|
|
466
|
-
//=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
470
|
-
|
|
471
|
-
```
|
|
472
|
-
type OmitIndexSignature<ObjectType> = {
|
|
473
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
474
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
475
|
-
};
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
479
|
-
|
|
480
|
-
```
|
|
481
|
-
type OmitIndexSignature<ObjectType> = {
|
|
482
|
-
[KeyType in keyof ObjectType
|
|
483
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
484
|
-
as {} extends Record<KeyType, unknown>
|
|
485
|
-
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
486
|
-
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
487
|
-
]: ObjectType[KeyType];
|
|
488
|
-
};
|
|
489
|
-
```
|
|
490
|
-
|
|
491
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
492
|
-
|
|
493
|
-
@example
|
|
494
|
-
```
|
|
495
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
496
|
-
|
|
497
|
-
type Example = {
|
|
498
|
-
// These index signatures will be removed.
|
|
499
|
-
[x: string]: any;
|
|
500
|
-
[x: number]: any;
|
|
501
|
-
[x: symbol]: any;
|
|
502
|
-
[x: `head-${string}`]: string;
|
|
503
|
-
[x: `${string}-tail`]: string;
|
|
504
|
-
[x: `head-${string}-tail`]: string;
|
|
505
|
-
[x: `${bigint}`]: string;
|
|
506
|
-
[x: `embedded-${number}`]: string;
|
|
507
|
-
|
|
508
|
-
// These explicitly defined keys will remain.
|
|
509
|
-
foo: 'bar';
|
|
510
|
-
qux?: 'baz';
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
514
|
-
//=> {foo: 'bar'; qux?: 'baz'}
|
|
515
|
-
```
|
|
516
|
-
|
|
517
|
-
@see {@link PickIndexSignature}
|
|
518
|
-
@category Object
|
|
519
|
-
*/
|
|
520
|
-
type OmitIndexSignature<ObjectType> = {
|
|
521
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
522
|
-
? never
|
|
523
|
-
: KeyType]: ObjectType[KeyType];
|
|
524
|
-
};
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
528
|
-
|
|
529
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
530
|
-
|
|
531
|
-
@example
|
|
532
|
-
```
|
|
533
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
534
|
-
|
|
535
|
-
declare const symbolKey: unique symbol;
|
|
536
|
-
|
|
537
|
-
type Example = {
|
|
538
|
-
// These index signatures will remain.
|
|
539
|
-
[x: string]: unknown;
|
|
540
|
-
[x: number]: unknown;
|
|
541
|
-
[x: symbol]: unknown;
|
|
542
|
-
[x: `head-${string}`]: string;
|
|
543
|
-
[x: `${string}-tail`]: string;
|
|
544
|
-
[x: `head-${string}-tail`]: string;
|
|
545
|
-
[x: `${bigint}`]: string;
|
|
546
|
-
[x: `embedded-${number}`]: string;
|
|
547
|
-
|
|
548
|
-
// These explicitly defined keys will be removed.
|
|
549
|
-
['kebab-case-key']: string;
|
|
550
|
-
[symbolKey]: string;
|
|
551
|
-
foo: 'bar';
|
|
552
|
-
qux?: 'baz';
|
|
553
|
-
};
|
|
554
|
-
|
|
555
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
556
|
-
// {
|
|
557
|
-
// [x: string]: unknown;
|
|
558
|
-
// [x: number]: unknown;
|
|
559
|
-
// [x: symbol]: unknown;
|
|
560
|
-
// [x: `head-${string}`]: string;
|
|
561
|
-
// [x: `${string}-tail`]: string;
|
|
562
|
-
// [x: `head-${string}-tail`]: string;
|
|
563
|
-
// [x: `${bigint}`]: string;
|
|
564
|
-
// [x: `embedded-${number}`]: string;
|
|
565
|
-
// }
|
|
566
|
-
```
|
|
567
|
-
|
|
568
|
-
@see {@link OmitIndexSignature}
|
|
569
|
-
@category Object
|
|
570
|
-
*/
|
|
571
|
-
type PickIndexSignature<ObjectType> = {
|
|
572
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
573
|
-
? KeyType
|
|
574
|
-
: never]: ObjectType[KeyType];
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
// Merges two objects without worrying about index signatures.
|
|
578
|
-
type SimpleMerge<Destination, Source> = Simplify<{
|
|
579
|
-
[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
|
|
580
|
-
} & Source>;
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
584
|
-
|
|
585
|
-
@example
|
|
586
|
-
```
|
|
587
|
-
import type {Merge} from 'type-fest';
|
|
588
|
-
|
|
589
|
-
type Foo = {
|
|
590
|
-
[x: string]: unknown;
|
|
591
|
-
[x: number]: unknown;
|
|
592
|
-
foo: string;
|
|
593
|
-
bar: symbol;
|
|
594
|
-
};
|
|
595
|
-
|
|
596
|
-
type Bar = {
|
|
597
|
-
[x: number]: number;
|
|
598
|
-
[x: symbol]: unknown;
|
|
599
|
-
bar: Date;
|
|
600
|
-
baz: boolean;
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
604
|
-
//=> {
|
|
605
|
-
// [x: string]: unknown;
|
|
606
|
-
// [x: number]: number;
|
|
607
|
-
// [x: symbol]: unknown;
|
|
608
|
-
// foo: string;
|
|
609
|
-
// bar: Date;
|
|
610
|
-
// baz: boolean;
|
|
611
|
-
// }
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
|
|
615
|
-
|
|
616
|
-
@see {@link ObjectMerge}
|
|
617
|
-
@category Object
|
|
618
|
-
*/
|
|
619
|
-
type Merge<Destination, Source> =
|
|
620
|
-
Destination extends unknown // For distributing `Destination`
|
|
621
|
-
? Source extends unknown // For distributing `Source`
|
|
622
|
-
? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>>
|
|
623
|
-
: never // Should never happen
|
|
624
|
-
: never; // Should never happen
|
|
625
|
-
|
|
626
|
-
type _Merge<Destination, Source> =
|
|
627
|
-
Simplify<
|
|
628
|
-
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
|
|
629
|
-
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
|
|
630
|
-
>;
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
Merges user specified options with default options.
|
|
634
|
-
|
|
635
|
-
@example
|
|
636
|
-
```
|
|
637
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
638
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
639
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
640
|
-
|
|
641
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
642
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
@example
|
|
646
|
-
```
|
|
647
|
-
// Complains if default values are not provided for optional options
|
|
648
|
-
|
|
649
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
650
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
651
|
-
type SpecifiedOptions = {};
|
|
652
|
-
|
|
653
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
654
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
655
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
656
|
-
```
|
|
657
|
-
|
|
658
|
-
@example
|
|
659
|
-
```
|
|
660
|
-
// Complains if an option's default type does not conform to the expected type
|
|
661
|
-
|
|
662
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
663
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
664
|
-
type SpecifiedOptions = {};
|
|
665
|
-
|
|
666
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
667
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
668
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
669
|
-
```
|
|
670
|
-
|
|
671
|
-
@example
|
|
672
|
-
```
|
|
673
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
674
|
-
|
|
675
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
676
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
677
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
678
|
-
|
|
679
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
680
|
-
// ~~~~~~~~~~~~~~~~
|
|
681
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
682
|
-
```
|
|
683
|
-
*/
|
|
684
|
-
type ApplyDefaultOptions<
|
|
685
|
-
Options extends object,
|
|
686
|
-
Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
|
|
687
|
-
SpecifiedOptions extends Options,
|
|
688
|
-
> =
|
|
689
|
-
If<IsAny<SpecifiedOptions>, Defaults,
|
|
690
|
-
If<IsNever<SpecifiedOptions>, Defaults,
|
|
691
|
-
Simplify<Merge<Defaults, {
|
|
692
|
-
[Key in keyof SpecifiedOptions
|
|
693
|
-
as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key
|
|
694
|
-
]: SpecifiedOptions[Key]
|
|
695
|
-
}> & Required<Options>>>>;
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
Create a type that represents either the value or an array of the value.
|
|
699
|
-
|
|
700
|
-
@see {@link Promisable}
|
|
701
|
-
|
|
702
|
-
@example
|
|
703
|
-
```
|
|
704
|
-
import type {Arrayable} from 'type-fest';
|
|
705
|
-
|
|
706
|
-
function bundle(input: string, output: Arrayable<string>) {
|
|
707
|
-
const outputList = Array.isArray(output) ? output : [output];
|
|
708
|
-
|
|
709
|
-
// …
|
|
710
|
-
|
|
711
|
-
for (const output of outputList) {
|
|
712
|
-
console.log(`write ${input} to: ${output}`);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
bundle('src/index.js', 'dist/index.js');
|
|
717
|
-
bundle('src/index.js', ['dist/index.cjs', 'dist/index.mjs']);
|
|
718
|
-
```
|
|
719
|
-
|
|
720
|
-
@category Array
|
|
721
|
-
*/
|
|
722
|
-
type Arrayable<T> =
|
|
723
|
-
T
|
|
724
|
-
// TODO: Use `readonly T[]` when this issue is resolved: https://github.com/microsoft/TypeScript/issues/17002
|
|
725
|
-
| T[];
|
|
726
|
-
|
|
727
|
-
type SetFieldTypeOptions = {
|
|
728
|
-
/**
|
|
729
|
-
Preserve optional and readonly modifiers for properties being updated.
|
|
730
|
-
|
|
731
|
-
NOTE: Property modifiers will always be preserved for properties that are not being updated.
|
|
732
|
-
|
|
733
|
-
@default true
|
|
734
|
-
*/
|
|
735
|
-
preservePropertyModifiers?: boolean;
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
type DefaultSetFieldTypeOptions = {
|
|
739
|
-
preservePropertyModifiers: true;
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
Create a type that changes the type of the given keys.
|
|
744
|
-
|
|
745
|
-
Use-cases:
|
|
746
|
-
- Creating variations of a base model.
|
|
747
|
-
- Fixing incorrect external types.
|
|
748
|
-
|
|
749
|
-
@see `Merge` if you need to change multiple properties to different types.
|
|
750
|
-
|
|
751
|
-
@example
|
|
752
|
-
```
|
|
753
|
-
import type {SetFieldType} from 'type-fest';
|
|
754
|
-
|
|
755
|
-
type MyModel = {
|
|
756
|
-
readonly id: number;
|
|
757
|
-
readonly createdAt: Date;
|
|
758
|
-
updatedAt?: Date;
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
type MyModelApi1 = SetFieldType<MyModel, 'createdAt' | 'updatedAt', string>;
|
|
762
|
-
// {
|
|
763
|
-
// readonly id: number;
|
|
764
|
-
// readonly createdAt: string;
|
|
765
|
-
// updatedAt?: string;
|
|
766
|
-
// }
|
|
767
|
-
|
|
768
|
-
// `preservePropertyModifiers` option can be set to `false` if you want to remove property modifiers for properties being updated
|
|
769
|
-
type MyModelApi2 = SetFieldType<MyModel, 'createdAt' | 'updatedAt', string, {preservePropertyModifiers: false}>;
|
|
770
|
-
// {
|
|
771
|
-
// readonly id: number;
|
|
772
|
-
// createdAt: string; // no longer readonly
|
|
773
|
-
// updatedAt: string; // no longer optional
|
|
774
|
-
// }
|
|
775
|
-
```
|
|
776
|
-
|
|
777
|
-
@category Object
|
|
778
|
-
*/
|
|
779
|
-
type SetFieldType<BaseType, Keys extends keyof BaseType, NewType, Options extends SetFieldTypeOptions = {}> =
|
|
780
|
-
_SetFieldType<BaseType, Keys, NewType, ApplyDefaultOptions<SetFieldTypeOptions, DefaultSetFieldTypeOptions, Options>>;
|
|
781
|
-
|
|
782
|
-
type _SetFieldType<BaseType, Keys extends keyof BaseType, NewType, Options extends Required<SetFieldTypeOptions>> =
|
|
783
|
-
Simplify<{
|
|
784
|
-
[P in keyof BaseType]: P extends Keys ? NewType : BaseType[P];
|
|
785
|
-
} & (
|
|
786
|
-
// `Record` is used to remove property modifiers
|
|
787
|
-
Options['preservePropertyModifiers'] extends false ? Record<Keys, NewType> : unknown
|
|
788
|
-
)>;
|
|
789
|
-
|
|
790
|
-
declare namespace TsConfigJson {
|
|
791
|
-
namespace CompilerOptions {
|
|
792
|
-
type JSX =
|
|
793
|
-
| 'preserve'
|
|
794
|
-
| 'react'
|
|
795
|
-
| 'react-jsx'
|
|
796
|
-
| 'react-jsxdev'
|
|
797
|
-
| 'react-native';
|
|
798
|
-
|
|
799
|
-
type Module =
|
|
800
|
-
| 'CommonJS'
|
|
801
|
-
| 'AMD'
|
|
802
|
-
| 'System'
|
|
803
|
-
| 'UMD'
|
|
804
|
-
| 'ES6'
|
|
805
|
-
| 'ES2015'
|
|
806
|
-
| 'ES2020'
|
|
807
|
-
| 'ES2022'
|
|
808
|
-
| 'ESNext'
|
|
809
|
-
| 'Node16'
|
|
810
|
-
| 'Node18'
|
|
811
|
-
| 'Node20'
|
|
812
|
-
| 'NodeNext'
|
|
813
|
-
| 'Preserve'
|
|
814
|
-
| 'None'
|
|
815
|
-
// Lowercase alternatives
|
|
816
|
-
| 'commonjs'
|
|
817
|
-
| 'amd'
|
|
818
|
-
| 'system'
|
|
819
|
-
| 'umd'
|
|
820
|
-
| 'es6'
|
|
821
|
-
| 'es2015'
|
|
822
|
-
| 'es2020'
|
|
823
|
-
| 'es2022'
|
|
824
|
-
| 'esnext'
|
|
825
|
-
| 'node16'
|
|
826
|
-
| 'node18'
|
|
827
|
-
| 'node20'
|
|
828
|
-
| 'nodenext'
|
|
829
|
-
| 'preserve'
|
|
830
|
-
| 'none';
|
|
831
|
-
|
|
832
|
-
type NewLine =
|
|
833
|
-
| 'CRLF'
|
|
834
|
-
| 'LF'
|
|
835
|
-
// Lowercase alternatives
|
|
836
|
-
| 'crlf'
|
|
837
|
-
| 'lf';
|
|
838
|
-
|
|
839
|
-
type Target =
|
|
840
|
-
| 'ES3'
|
|
841
|
-
| 'ES5'
|
|
842
|
-
| 'ES6'
|
|
843
|
-
| 'ES2015'
|
|
844
|
-
| 'ES2016'
|
|
845
|
-
| 'ES2017'
|
|
846
|
-
| 'ES2018'
|
|
847
|
-
| 'ES2019'
|
|
848
|
-
| 'ES2020'
|
|
849
|
-
| 'ES2021'
|
|
850
|
-
| 'ES2022'
|
|
851
|
-
| 'ES2023'
|
|
852
|
-
| 'ES2024'
|
|
853
|
-
| 'ESNext'
|
|
854
|
-
// Lowercase alternatives
|
|
855
|
-
| 'es3'
|
|
856
|
-
| 'es5'
|
|
857
|
-
| 'es6'
|
|
858
|
-
| 'es2015'
|
|
859
|
-
| 'es2016'
|
|
860
|
-
| 'es2017'
|
|
861
|
-
| 'es2018'
|
|
862
|
-
| 'es2019'
|
|
863
|
-
| 'es2020'
|
|
864
|
-
| 'es2021'
|
|
865
|
-
| 'es2022'
|
|
866
|
-
| 'es2023'
|
|
867
|
-
| 'es2024'
|
|
868
|
-
| 'esnext';
|
|
869
|
-
|
|
870
|
-
type Lib =
|
|
871
|
-
| 'ES5'
|
|
872
|
-
| 'ES6'
|
|
873
|
-
| 'ES7'
|
|
874
|
-
| 'ES2015'
|
|
875
|
-
| 'ES2015.Collection'
|
|
876
|
-
| 'ES2015.Core'
|
|
877
|
-
| 'ES2015.Generator'
|
|
878
|
-
| 'ES2015.Iterable'
|
|
879
|
-
| 'ES2015.Promise'
|
|
880
|
-
| 'ES2015.Proxy'
|
|
881
|
-
| 'ES2015.Reflect'
|
|
882
|
-
| 'ES2015.Symbol.WellKnown'
|
|
883
|
-
| 'ES2015.Symbol'
|
|
884
|
-
| 'ES2016'
|
|
885
|
-
| 'ES2016.Array.Include'
|
|
886
|
-
| 'ES2017'
|
|
887
|
-
| 'ES2017.ArrayBuffer'
|
|
888
|
-
| 'ES2017.Date'
|
|
889
|
-
| 'ES2017.Intl'
|
|
890
|
-
| 'ES2017.Object'
|
|
891
|
-
| 'ES2017.SharedMemory'
|
|
892
|
-
| 'ES2017.String'
|
|
893
|
-
| 'ES2017.TypedArrays'
|
|
894
|
-
| 'ES2018'
|
|
895
|
-
| 'ES2018.AsyncGenerator'
|
|
896
|
-
| 'ES2018.AsyncIterable'
|
|
897
|
-
| 'ES2018.Intl'
|
|
898
|
-
| 'ES2018.Promise'
|
|
899
|
-
| 'ES2018.Regexp'
|
|
900
|
-
| 'ES2019'
|
|
901
|
-
| 'ES2019.Array'
|
|
902
|
-
| 'ES2019.Intl'
|
|
903
|
-
| 'ES2019.Object'
|
|
904
|
-
| 'ES2019.String'
|
|
905
|
-
| 'ES2019.Symbol'
|
|
906
|
-
| 'ES2020'
|
|
907
|
-
| 'ES2020.BigInt'
|
|
908
|
-
| 'ES2020.Date'
|
|
909
|
-
| 'ES2020.Intl'
|
|
910
|
-
| 'ES2020.Number'
|
|
911
|
-
| 'ES2020.Promise'
|
|
912
|
-
| 'ES2020.SharedMemory'
|
|
913
|
-
| 'ES2020.String'
|
|
914
|
-
| 'ES2020.Symbol.WellKnown'
|
|
915
|
-
| 'ES2021'
|
|
916
|
-
| 'ES2021.Intl'
|
|
917
|
-
| 'ES2021.Promise'
|
|
918
|
-
| 'ES2021.String'
|
|
919
|
-
| 'ES2021.WeakRef'
|
|
920
|
-
| 'ES2022'
|
|
921
|
-
| 'ES2022.Array'
|
|
922
|
-
| 'ES2022.Error'
|
|
923
|
-
| 'ES2022.Intl'
|
|
924
|
-
| 'ES2022.Object'
|
|
925
|
-
| 'ES2022.RegExp'
|
|
926
|
-
| 'ES2022.SharedMemory'
|
|
927
|
-
| 'ES2022.String'
|
|
928
|
-
| 'ES2023'
|
|
929
|
-
| 'ES2023.Array'
|
|
930
|
-
| 'ES2023.Collection'
|
|
931
|
-
| 'ES2023.Intl'
|
|
932
|
-
| 'ES2024'
|
|
933
|
-
| 'ES2024.ArrayBuffer'
|
|
934
|
-
| 'ES2024.Collection'
|
|
935
|
-
| 'ES2024.Object'
|
|
936
|
-
| 'ES2024.Promise'
|
|
937
|
-
| 'ES2024.Regexp'
|
|
938
|
-
| 'ES2024.SharedMemory'
|
|
939
|
-
| 'ES2024.String'
|
|
940
|
-
| 'ESNext'
|
|
941
|
-
| 'ESNext.Array'
|
|
942
|
-
| 'ESNext.AsyncIterable'
|
|
943
|
-
| 'ESNext.BigInt'
|
|
944
|
-
| 'ESNext.Collection'
|
|
945
|
-
| 'ESNext.Decorators'
|
|
946
|
-
| 'ESNext.Disposable'
|
|
947
|
-
| 'ESNext.Error'
|
|
948
|
-
| 'ESNext.Intl'
|
|
949
|
-
| 'ESNext.Iterator'
|
|
950
|
-
| 'ESNext.Object'
|
|
951
|
-
| 'ESNext.Promise'
|
|
952
|
-
| 'ESNext.Regexp'
|
|
953
|
-
| 'ESNext.String'
|
|
954
|
-
| 'ESNext.Symbol'
|
|
955
|
-
| 'ESNext.WeakRef'
|
|
956
|
-
| 'DOM'
|
|
957
|
-
| 'DOM.AsyncIterable'
|
|
958
|
-
| 'DOM.Iterable'
|
|
959
|
-
| 'Decorators'
|
|
960
|
-
| 'Decorators.Legacy'
|
|
961
|
-
| 'ScriptHost'
|
|
962
|
-
| 'WebWorker'
|
|
963
|
-
| 'WebWorker.AsyncIterable'
|
|
964
|
-
| 'WebWorker.ImportScripts'
|
|
965
|
-
| 'WebWorker.Iterable'
|
|
966
|
-
// Lowercase alternatives
|
|
967
|
-
| 'es5'
|
|
968
|
-
| 'es6'
|
|
969
|
-
| 'es7'
|
|
970
|
-
| 'es2015'
|
|
971
|
-
| 'es2015.collection'
|
|
972
|
-
| 'es2015.core'
|
|
973
|
-
| 'es2015.generator'
|
|
974
|
-
| 'es2015.iterable'
|
|
975
|
-
| 'es2015.promise'
|
|
976
|
-
| 'es2015.proxy'
|
|
977
|
-
| 'es2015.reflect'
|
|
978
|
-
| 'es2015.symbol.wellknown'
|
|
979
|
-
| 'es2015.symbol'
|
|
980
|
-
| 'es2016'
|
|
981
|
-
| 'es2016.array.include'
|
|
982
|
-
| 'es2017'
|
|
983
|
-
| 'es2017.arraybuffer'
|
|
984
|
-
| 'es2017.date'
|
|
985
|
-
| 'es2017.intl'
|
|
986
|
-
| 'es2017.object'
|
|
987
|
-
| 'es2017.sharedmemory'
|
|
988
|
-
| 'es2017.string'
|
|
989
|
-
| 'es2017.typedarrays'
|
|
990
|
-
| 'es2018'
|
|
991
|
-
| 'es2018.asyncgenerator'
|
|
992
|
-
| 'es2018.asynciterable'
|
|
993
|
-
| 'es2018.intl'
|
|
994
|
-
| 'es2018.promise'
|
|
995
|
-
| 'es2018.regexp'
|
|
996
|
-
| 'es2019'
|
|
997
|
-
| 'es2019.array'
|
|
998
|
-
| 'es2019.intl'
|
|
999
|
-
| 'es2019.object'
|
|
1000
|
-
| 'es2019.string'
|
|
1001
|
-
| 'es2019.symbol'
|
|
1002
|
-
| 'es2020'
|
|
1003
|
-
| 'es2020.bigint'
|
|
1004
|
-
| 'es2020.date'
|
|
1005
|
-
| 'es2020.intl'
|
|
1006
|
-
| 'es2020.number'
|
|
1007
|
-
| 'es2020.promise'
|
|
1008
|
-
| 'es2020.sharedmemory'
|
|
1009
|
-
| 'es2020.string'
|
|
1010
|
-
| 'es2020.symbol.wellknown'
|
|
1011
|
-
| 'es2021'
|
|
1012
|
-
| 'es2021.intl'
|
|
1013
|
-
| 'es2021.promise'
|
|
1014
|
-
| 'es2021.string'
|
|
1015
|
-
| 'es2021.weakref'
|
|
1016
|
-
| 'es2022'
|
|
1017
|
-
| 'es2022.array'
|
|
1018
|
-
| 'es2022.error'
|
|
1019
|
-
| 'es2022.intl'
|
|
1020
|
-
| 'es2022.object'
|
|
1021
|
-
| 'es2022.regexp'
|
|
1022
|
-
| 'es2022.sharedmemory'
|
|
1023
|
-
| 'es2022.string'
|
|
1024
|
-
| 'es2023'
|
|
1025
|
-
| 'es2023.array'
|
|
1026
|
-
| 'es2023.collection'
|
|
1027
|
-
| 'es2023.intl'
|
|
1028
|
-
| 'es2024'
|
|
1029
|
-
| 'es2024.arraybuffer'
|
|
1030
|
-
| 'es2024.collection'
|
|
1031
|
-
| 'es2024.object'
|
|
1032
|
-
| 'es2024.promise'
|
|
1033
|
-
| 'es2024.regexp'
|
|
1034
|
-
| 'es2024.sharedmemory'
|
|
1035
|
-
| 'es2024.string'
|
|
1036
|
-
| 'esnext'
|
|
1037
|
-
| 'esnext.array'
|
|
1038
|
-
| 'esnext.asynciterable'
|
|
1039
|
-
| 'esnext.bigint'
|
|
1040
|
-
| 'esnext.collection'
|
|
1041
|
-
| 'esnext.decorators'
|
|
1042
|
-
| 'esnext.disposable'
|
|
1043
|
-
| 'esnext.error'
|
|
1044
|
-
| 'esnext.intl'
|
|
1045
|
-
| 'esnext.iterator'
|
|
1046
|
-
| 'esnext.object'
|
|
1047
|
-
| 'esnext.promise'
|
|
1048
|
-
| 'esnext.regexp'
|
|
1049
|
-
| 'esnext.string'
|
|
1050
|
-
| 'esnext.symbol'
|
|
1051
|
-
| 'esnext.weakref'
|
|
1052
|
-
| 'dom'
|
|
1053
|
-
| 'dom.asynciterable'
|
|
1054
|
-
| 'dom.iterable'
|
|
1055
|
-
| 'decorators'
|
|
1056
|
-
| 'decorators.legacy'
|
|
1057
|
-
| 'scripthost'
|
|
1058
|
-
| 'webworker'
|
|
1059
|
-
| 'webworker.asynciterable'
|
|
1060
|
-
| 'webworker.importscripts'
|
|
1061
|
-
| 'webworker.iterable';
|
|
1062
|
-
|
|
1063
|
-
type Plugin = {
|
|
1064
|
-
/**
|
|
1065
|
-
Plugin name.
|
|
1066
|
-
*/
|
|
1067
|
-
name: string;
|
|
1068
|
-
};
|
|
1069
|
-
|
|
1070
|
-
type ImportsNotUsedAsValues =
|
|
1071
|
-
| 'remove'
|
|
1072
|
-
| 'preserve'
|
|
1073
|
-
| 'error';
|
|
1074
|
-
|
|
1075
|
-
type FallbackPolling =
|
|
1076
|
-
| 'fixedPollingInterval'
|
|
1077
|
-
| 'priorityPollingInterval'
|
|
1078
|
-
| 'dynamicPriorityPolling'
|
|
1079
|
-
| 'fixedInterval'
|
|
1080
|
-
| 'priorityInterval'
|
|
1081
|
-
| 'dynamicPriority'
|
|
1082
|
-
| 'fixedChunkSize';
|
|
1083
|
-
|
|
1084
|
-
type WatchDirectory =
|
|
1085
|
-
| 'useFsEvents'
|
|
1086
|
-
| 'fixedPollingInterval'
|
|
1087
|
-
| 'dynamicPriorityPolling'
|
|
1088
|
-
| 'fixedChunkSizePolling';
|
|
1089
|
-
|
|
1090
|
-
type WatchFile =
|
|
1091
|
-
| 'fixedPollingInterval'
|
|
1092
|
-
| 'priorityPollingInterval'
|
|
1093
|
-
| 'dynamicPriorityPolling'
|
|
1094
|
-
| 'useFsEvents'
|
|
1095
|
-
| 'useFsEventsOnParentDirectory'
|
|
1096
|
-
| 'fixedChunkSizePolling';
|
|
1097
|
-
|
|
1098
|
-
type ModuleResolution =
|
|
1099
|
-
| 'classic'
|
|
1100
|
-
| 'node'
|
|
1101
|
-
| 'node10'
|
|
1102
|
-
| 'node16'
|
|
1103
|
-
| 'nodenext'
|
|
1104
|
-
| 'bundler'
|
|
1105
|
-
// Pascal-cased alternatives
|
|
1106
|
-
| 'Classic'
|
|
1107
|
-
| 'Node'
|
|
1108
|
-
| 'Node10'
|
|
1109
|
-
| 'Node16'
|
|
1110
|
-
| 'NodeNext'
|
|
1111
|
-
| 'Bundler';
|
|
1112
|
-
|
|
1113
|
-
type ModuleDetection =
|
|
1114
|
-
| 'auto'
|
|
1115
|
-
| 'legacy'
|
|
1116
|
-
| 'force';
|
|
1117
|
-
|
|
1118
|
-
type IgnoreDeprecations = '5.0';
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
type CompilerOptions = {
|
|
1122
|
-
/**
|
|
1123
|
-
The character set of the input files.
|
|
1124
|
-
|
|
1125
|
-
@default 'utf8'
|
|
1126
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
1127
|
-
*/
|
|
1128
|
-
charset?: string;
|
|
1129
|
-
|
|
1130
|
-
/**
|
|
1131
|
-
Enables building for project references.
|
|
1132
|
-
|
|
1133
|
-
@default true
|
|
1134
|
-
*/
|
|
1135
|
-
composite?: boolean;
|
|
1136
|
-
|
|
1137
|
-
/**
|
|
1138
|
-
Generates corresponding d.ts files.
|
|
1139
|
-
|
|
1140
|
-
@default false
|
|
1141
|
-
*/
|
|
1142
|
-
declaration?: boolean;
|
|
1143
|
-
|
|
1144
|
-
/**
|
|
1145
|
-
Specify output directory for generated declaration files.
|
|
1146
|
-
*/
|
|
1147
|
-
declarationDir?: string;
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
Show diagnostic information.
|
|
1151
|
-
|
|
1152
|
-
@default false
|
|
1153
|
-
*/
|
|
1154
|
-
diagnostics?: boolean;
|
|
1155
|
-
|
|
1156
|
-
/**
|
|
1157
|
-
Reduce the number of projects loaded automatically by TypeScript.
|
|
1158
|
-
|
|
1159
|
-
@default false
|
|
1160
|
-
*/
|
|
1161
|
-
disableReferencedProjectLoad?: boolean;
|
|
1162
|
-
|
|
1163
|
-
/**
|
|
1164
|
-
Enforces using indexed accessors for keys declared using an indexed type.
|
|
1165
|
-
|
|
1166
|
-
@default false
|
|
1167
|
-
*/
|
|
1168
|
-
noPropertyAccessFromIndexSignature?: boolean;
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
|
|
1172
|
-
|
|
1173
|
-
@default false
|
|
1174
|
-
*/
|
|
1175
|
-
emitBOM?: boolean;
|
|
1176
|
-
|
|
1177
|
-
/**
|
|
1178
|
-
Only emit `.d.ts` declaration files.
|
|
1179
|
-
|
|
1180
|
-
@default false
|
|
1181
|
-
*/
|
|
1182
|
-
emitDeclarationOnly?: boolean;
|
|
1183
|
-
|
|
1184
|
-
/**
|
|
1185
|
-
Differentiate between undefined and not present when type checking.
|
|
1186
|
-
|
|
1187
|
-
@default false
|
|
1188
|
-
*/
|
|
1189
|
-
exactOptionalPropertyTypes?: boolean;
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
Enable incremental compilation.
|
|
1193
|
-
|
|
1194
|
-
@default `composite`
|
|
1195
|
-
*/
|
|
1196
|
-
incremental?: boolean;
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
Specify file to store incremental compilation information.
|
|
1200
|
-
|
|
1201
|
-
@default '.tsbuildinfo'
|
|
1202
|
-
*/
|
|
1203
|
-
tsBuildInfoFile?: string;
|
|
1204
|
-
|
|
1205
|
-
/**
|
|
1206
|
-
Emit a single file with source maps instead of having a separate file.
|
|
1207
|
-
|
|
1208
|
-
@default false
|
|
1209
|
-
*/
|
|
1210
|
-
inlineSourceMap?: boolean;
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
Emit the source alongside the sourcemaps within a single file.
|
|
1214
|
-
|
|
1215
|
-
Requires `--inlineSourceMap` to be set.
|
|
1216
|
-
|
|
1217
|
-
@default false
|
|
1218
|
-
*/
|
|
1219
|
-
inlineSources?: boolean;
|
|
1220
|
-
|
|
1221
|
-
/**
|
|
1222
|
-
Specify what JSX code is generated.
|
|
1223
|
-
|
|
1224
|
-
@default 'preserve'
|
|
1225
|
-
*/
|
|
1226
|
-
jsx?: CompilerOptions.JSX;
|
|
1227
|
-
|
|
1228
|
-
/**
|
|
1229
|
-
Specifies the object invoked for `createElement` and `__spread` when targeting `'react'` JSX emit.
|
|
1230
|
-
|
|
1231
|
-
@default 'React'
|
|
1232
|
-
*/
|
|
1233
|
-
reactNamespace?: string;
|
|
1234
|
-
|
|
1235
|
-
/**
|
|
1236
|
-
Specify the JSX factory function to use when targeting React JSX emit, e.g. `React.createElement` or `h`.
|
|
1237
|
-
|
|
1238
|
-
@default 'React.createElement'
|
|
1239
|
-
*/
|
|
1240
|
-
jsxFactory?: string;
|
|
1241
|
-
|
|
1242
|
-
/**
|
|
1243
|
-
Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
|
|
1244
|
-
|
|
1245
|
-
@default 'React.Fragment'
|
|
1246
|
-
*/
|
|
1247
|
-
jsxFragmentFactory?: string;
|
|
1248
|
-
|
|
1249
|
-
/**
|
|
1250
|
-
Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.
|
|
1251
|
-
|
|
1252
|
-
@default 'react'
|
|
1253
|
-
*/
|
|
1254
|
-
jsxImportSource?: string;
|
|
1255
|
-
|
|
1256
|
-
/**
|
|
1257
|
-
Print names of files part of the compilation.
|
|
1258
|
-
|
|
1259
|
-
@default false
|
|
1260
|
-
*/
|
|
1261
|
-
listFiles?: boolean;
|
|
1262
|
-
|
|
1263
|
-
/**
|
|
1264
|
-
Specifies the location where debugger should locate map files instead of generated locations.
|
|
1265
|
-
*/
|
|
1266
|
-
mapRoot?: string;
|
|
1267
|
-
|
|
1268
|
-
/**
|
|
1269
|
-
Specify module code generation: 'None', 'CommonJS', 'AMD', 'System', 'UMD', 'ES6', 'ES2015' or 'ESNext'. Only 'AMD' and 'System' can be used in conjunction with `--outFile`. 'ES6' and 'ES2015' values may be used when targeting 'ES5' or lower.
|
|
1270
|
-
|
|
1271
|
-
@default ['ES3', 'ES5'].includes(target) ? 'CommonJS' : 'ES6'
|
|
1272
|
-
*/
|
|
1273
|
-
module?: CompilerOptions.Module;
|
|
1274
|
-
|
|
1275
|
-
/**
|
|
1276
|
-
Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6).
|
|
1277
|
-
|
|
1278
|
-
@default ['AMD', 'System', 'ES6'].includes(module) ? 'classic' : 'node'
|
|
1279
|
-
*/
|
|
1280
|
-
moduleResolution?: CompilerOptions.ModuleResolution;
|
|
1281
|
-
|
|
1282
|
-
/**
|
|
1283
|
-
Specifies the end of line sequence to be used when emitting files: 'crlf' (Windows) or 'lf' (Unix).
|
|
1284
|
-
|
|
1285
|
-
@default 'LF'
|
|
1286
|
-
*/
|
|
1287
|
-
newLine?: CompilerOptions.NewLine;
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
Disable full type checking (only critical parse and emit errors will be reported).
|
|
1291
|
-
|
|
1292
|
-
@default false
|
|
1293
|
-
*/
|
|
1294
|
-
noCheck?: boolean;
|
|
1295
|
-
|
|
1296
|
-
/**
|
|
1297
|
-
Do not emit output.
|
|
1298
|
-
|
|
1299
|
-
@default false
|
|
1300
|
-
*/
|
|
1301
|
-
noEmit?: boolean;
|
|
1302
|
-
|
|
1303
|
-
/**
|
|
1304
|
-
Do not generate custom helper functions like `__extends` in compiled output.
|
|
1305
|
-
|
|
1306
|
-
@default false
|
|
1307
|
-
*/
|
|
1308
|
-
noEmitHelpers?: boolean;
|
|
1309
|
-
|
|
1310
|
-
/**
|
|
1311
|
-
Do not emit outputs if any type checking errors were reported.
|
|
1312
|
-
|
|
1313
|
-
@default false
|
|
1314
|
-
*/
|
|
1315
|
-
noEmitOnError?: boolean;
|
|
1316
|
-
|
|
1317
|
-
/**
|
|
1318
|
-
Warn on expressions and declarations with an implied 'any' type.
|
|
1319
|
-
|
|
1320
|
-
@default false
|
|
1321
|
-
*/
|
|
1322
|
-
noImplicitAny?: boolean;
|
|
1323
|
-
|
|
1324
|
-
/**
|
|
1325
|
-
Raise error on 'this' expressions with an implied any type.
|
|
1326
|
-
|
|
1327
|
-
@default false
|
|
1328
|
-
*/
|
|
1329
|
-
noImplicitThis?: boolean;
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
Report errors on unused locals.
|
|
1333
|
-
|
|
1334
|
-
@default false
|
|
1335
|
-
*/
|
|
1336
|
-
noUnusedLocals?: boolean;
|
|
1337
|
-
|
|
1338
|
-
/**
|
|
1339
|
-
Report errors on unused parameters.
|
|
1340
|
-
|
|
1341
|
-
@default false
|
|
1342
|
-
*/
|
|
1343
|
-
noUnusedParameters?: boolean;
|
|
1344
|
-
|
|
1345
|
-
/**
|
|
1346
|
-
Do not include the default library file (lib.d.ts).
|
|
1347
|
-
|
|
1348
|
-
@default false
|
|
1349
|
-
*/
|
|
1350
|
-
noLib?: boolean;
|
|
1351
|
-
|
|
1352
|
-
/**
|
|
1353
|
-
Do not add triple-slash references or module import targets to the list of compiled files.
|
|
1354
|
-
|
|
1355
|
-
@default false
|
|
1356
|
-
*/
|
|
1357
|
-
noResolve?: boolean;
|
|
1358
|
-
|
|
1359
|
-
/**
|
|
1360
|
-
Disable strict checking of generic signatures in function types.
|
|
1361
|
-
|
|
1362
|
-
@default false
|
|
1363
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
1364
|
-
*/
|
|
1365
|
-
noStrictGenericChecks?: boolean;
|
|
1366
|
-
|
|
1367
|
-
/**
|
|
1368
|
-
@deprecated use `skipLibCheck` instead.
|
|
1369
|
-
*/
|
|
1370
|
-
skipDefaultLibCheck?: boolean;
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
Skip type checking of declaration files.
|
|
1374
|
-
|
|
1375
|
-
@default false
|
|
1376
|
-
*/
|
|
1377
|
-
skipLibCheck?: boolean;
|
|
1378
|
-
|
|
1379
|
-
/**
|
|
1380
|
-
Concatenate and emit output to single file.
|
|
1381
|
-
*/
|
|
1382
|
-
outFile?: string;
|
|
1383
|
-
|
|
1384
|
-
/**
|
|
1385
|
-
Redirect output structure to the directory.
|
|
1386
|
-
*/
|
|
1387
|
-
outDir?: string;
|
|
1388
|
-
|
|
1389
|
-
/**
|
|
1390
|
-
Do not erase const enum declarations in generated code.
|
|
1391
|
-
|
|
1392
|
-
@default false
|
|
1393
|
-
*/
|
|
1394
|
-
preserveConstEnums?: boolean;
|
|
1395
|
-
|
|
1396
|
-
/**
|
|
1397
|
-
Do not resolve symlinks to their real path; treat a symlinked file like a real one.
|
|
1398
|
-
|
|
1399
|
-
@default false
|
|
1400
|
-
*/
|
|
1401
|
-
preserveSymlinks?: boolean;
|
|
1402
|
-
|
|
1403
|
-
/**
|
|
1404
|
-
Keep outdated console output in watch mode instead of clearing the screen.
|
|
1405
|
-
|
|
1406
|
-
@default false
|
|
1407
|
-
*/
|
|
1408
|
-
preserveWatchOutput?: boolean;
|
|
1409
|
-
|
|
1410
|
-
/**
|
|
1411
|
-
Stylize errors and messages using color and context (experimental).
|
|
1412
|
-
|
|
1413
|
-
@default true // Unless piping to another program or redirecting output to a file.
|
|
1414
|
-
*/
|
|
1415
|
-
pretty?: boolean;
|
|
1416
|
-
|
|
1417
|
-
/**
|
|
1418
|
-
Do not emit comments to output.
|
|
1419
|
-
|
|
1420
|
-
@default false
|
|
1421
|
-
*/
|
|
1422
|
-
removeComments?: boolean;
|
|
1423
|
-
|
|
1424
|
-
/**
|
|
1425
|
-
Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files.
|
|
1426
|
-
|
|
1427
|
-
@default false
|
|
1428
|
-
*/
|
|
1429
|
-
rewriteRelativeImportExtensions?: boolean;
|
|
1430
|
-
|
|
1431
|
-
/**
|
|
1432
|
-
Specifies the root directory of input files.
|
|
1433
|
-
|
|
1434
|
-
Use to control the output directory structure with `--outDir`.
|
|
1435
|
-
*/
|
|
1436
|
-
rootDir?: string;
|
|
1437
|
-
|
|
1438
|
-
/**
|
|
1439
|
-
Unconditionally emit imports for unresolved files.
|
|
1440
|
-
|
|
1441
|
-
@default false
|
|
1442
|
-
*/
|
|
1443
|
-
isolatedModules?: boolean;
|
|
1444
|
-
|
|
1445
|
-
/**
|
|
1446
|
-
Require sufficient annotation on exports so other tools can trivially generate declaration files.
|
|
1447
|
-
|
|
1448
|
-
@default false
|
|
1449
|
-
*/
|
|
1450
|
-
isolatedDeclarations?: boolean;
|
|
1451
|
-
|
|
1452
|
-
/**
|
|
1453
|
-
Generates corresponding '.map' file.
|
|
1454
|
-
|
|
1455
|
-
@default false
|
|
1456
|
-
*/
|
|
1457
|
-
sourceMap?: boolean;
|
|
1458
|
-
|
|
1459
|
-
/**
|
|
1460
|
-
Specifies the location where debugger should locate TypeScript files instead of source locations.
|
|
1461
|
-
*/
|
|
1462
|
-
sourceRoot?: string;
|
|
1463
|
-
|
|
1464
|
-
/**
|
|
1465
|
-
Suppress excess property checks for object literals.
|
|
1466
|
-
|
|
1467
|
-
@default false
|
|
1468
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
1469
|
-
*/
|
|
1470
|
-
suppressExcessPropertyErrors?: boolean;
|
|
1471
|
-
|
|
1472
|
-
/**
|
|
1473
|
-
Suppress noImplicitAny errors for indexing objects lacking index signatures.
|
|
1474
|
-
|
|
1475
|
-
@default false
|
|
1476
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
1477
|
-
*/
|
|
1478
|
-
suppressImplicitAnyIndexErrors?: boolean;
|
|
1479
|
-
|
|
1480
|
-
/**
|
|
1481
|
-
Do not emit declarations for code that has an `@internal` annotation.
|
|
1482
|
-
*/
|
|
1483
|
-
stripInternal?: boolean;
|
|
1484
|
-
|
|
1485
|
-
/**
|
|
1486
|
-
Specify ECMAScript target version.
|
|
1487
|
-
|
|
1488
|
-
@default 'es3'
|
|
1489
|
-
*/
|
|
1490
|
-
target?: CompilerOptions.Target;
|
|
1491
|
-
|
|
1492
|
-
/**
|
|
1493
|
-
Default catch clause variables as `unknown` instead of `any`.
|
|
1494
|
-
|
|
1495
|
-
@default false
|
|
1496
|
-
*/
|
|
1497
|
-
useUnknownInCatchVariables?: boolean;
|
|
1498
|
-
|
|
1499
|
-
/**
|
|
1500
|
-
Watch input files.
|
|
1501
|
-
|
|
1502
|
-
@default false
|
|
1503
|
-
@deprecated Use watchOptions instead.
|
|
1504
|
-
*/
|
|
1505
|
-
watch?: boolean;
|
|
1506
|
-
|
|
1507
|
-
/**
|
|
1508
|
-
Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
|
|
1509
|
-
|
|
1510
|
-
@deprecated Use watchOptions.fallbackPolling instead.
|
|
1511
|
-
*/
|
|
1512
|
-
fallbackPolling?: CompilerOptions.FallbackPolling;
|
|
1513
|
-
|
|
1514
|
-
/**
|
|
1515
|
-
Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
|
|
1516
|
-
|
|
1517
|
-
@default 'useFsEvents'
|
|
1518
|
-
@deprecated Use watchOptions.watchDirectory instead.
|
|
1519
|
-
*/
|
|
1520
|
-
watchDirectory?: CompilerOptions.WatchDirectory;
|
|
1521
|
-
|
|
1522
|
-
/**
|
|
1523
|
-
Specify the strategy for watching individual files.
|
|
1524
|
-
|
|
1525
|
-
@default 'useFsEvents'
|
|
1526
|
-
@deprecated Use watchOptions.watchFile instead.
|
|
1527
|
-
*/
|
|
1528
|
-
watchFile?: CompilerOptions.WatchFile;
|
|
1529
|
-
|
|
1530
|
-
/**
|
|
1531
|
-
Enables experimental support for ES7 decorators.
|
|
1532
|
-
|
|
1533
|
-
@default false
|
|
1534
|
-
*/
|
|
1535
|
-
experimentalDecorators?: boolean;
|
|
1536
|
-
|
|
1537
|
-
/**
|
|
1538
|
-
Emit design-type metadata for decorated declarations in source.
|
|
1539
|
-
|
|
1540
|
-
@default false
|
|
1541
|
-
*/
|
|
1542
|
-
emitDecoratorMetadata?: boolean;
|
|
1543
|
-
|
|
1544
|
-
/**
|
|
1545
|
-
Do not report errors on unused labels.
|
|
1546
|
-
|
|
1547
|
-
@default false
|
|
1548
|
-
*/
|
|
1549
|
-
allowUnusedLabels?: boolean;
|
|
1550
|
-
|
|
1551
|
-
/**
|
|
1552
|
-
Report error when not all code paths in function return a value.
|
|
1553
|
-
|
|
1554
|
-
@default false
|
|
1555
|
-
*/
|
|
1556
|
-
noImplicitReturns?: boolean;
|
|
1557
|
-
|
|
1558
|
-
/**
|
|
1559
|
-
Add `undefined` to a type when accessed using an index.
|
|
1560
|
-
|
|
1561
|
-
@default false
|
|
1562
|
-
*/
|
|
1563
|
-
noUncheckedIndexedAccess?: boolean;
|
|
1564
|
-
|
|
1565
|
-
/**
|
|
1566
|
-
Report error if failed to find a source file for a side effect import.
|
|
1567
|
-
|
|
1568
|
-
@default false
|
|
1569
|
-
*/
|
|
1570
|
-
noUncheckedSideEffectImports?: boolean;
|
|
1571
|
-
|
|
1572
|
-
/**
|
|
1573
|
-
Report errors for fallthrough cases in switch statement.
|
|
1574
|
-
|
|
1575
|
-
@default false
|
|
1576
|
-
*/
|
|
1577
|
-
noFallthroughCasesInSwitch?: boolean;
|
|
1578
|
-
|
|
1579
|
-
/**
|
|
1580
|
-
Ensure overriding members in derived classes are marked with an override modifier.
|
|
1581
|
-
|
|
1582
|
-
@default false
|
|
1583
|
-
*/
|
|
1584
|
-
noImplicitOverride?: boolean;
|
|
1585
|
-
|
|
1586
|
-
/**
|
|
1587
|
-
Do not report errors on unreachable code.
|
|
1588
|
-
|
|
1589
|
-
@default false
|
|
1590
|
-
*/
|
|
1591
|
-
allowUnreachableCode?: boolean;
|
|
1592
|
-
|
|
1593
|
-
/**
|
|
1594
|
-
Disallow inconsistently-cased references to the same file.
|
|
1595
|
-
|
|
1596
|
-
@default true
|
|
1597
|
-
*/
|
|
1598
|
-
forceConsistentCasingInFileNames?: boolean;
|
|
1599
|
-
|
|
1600
|
-
/**
|
|
1601
|
-
Emit a v8 CPU profile of the compiler run for debugging.
|
|
1602
|
-
|
|
1603
|
-
@default 'profile.cpuprofile'
|
|
1604
|
-
*/
|
|
1605
|
-
generateCpuProfile?: string;
|
|
1606
|
-
|
|
1607
|
-
/**
|
|
1608
|
-
Generates an event trace and a list of types.
|
|
1609
|
-
*/
|
|
1610
|
-
generateTrace?: boolean;
|
|
1611
|
-
|
|
1612
|
-
/**
|
|
1613
|
-
Base directory to resolve non-relative module names.
|
|
1614
|
-
*/
|
|
1615
|
-
baseUrl?: string;
|
|
1616
|
-
|
|
1617
|
-
/**
|
|
1618
|
-
Specify path mapping to be computed relative to baseUrl option.
|
|
1619
|
-
*/
|
|
1620
|
-
paths?: Record<string, string[]>;
|
|
1621
|
-
|
|
1622
|
-
/**
|
|
1623
|
-
List of TypeScript language server plugins to load.
|
|
1624
|
-
*/
|
|
1625
|
-
plugins?: CompilerOptions.Plugin[];
|
|
1626
|
-
|
|
1627
|
-
/**
|
|
1628
|
-
Specify list of root directories to be used when resolving modules.
|
|
1629
|
-
*/
|
|
1630
|
-
rootDirs?: string[];
|
|
1631
|
-
|
|
1632
|
-
/**
|
|
1633
|
-
Specify list of directories for type definition files to be included.
|
|
1634
|
-
*/
|
|
1635
|
-
typeRoots?: string[];
|
|
1636
|
-
|
|
1637
|
-
/**
|
|
1638
|
-
Type declaration files to be included in compilation.
|
|
1639
|
-
*/
|
|
1640
|
-
types?: string[];
|
|
1641
|
-
|
|
1642
|
-
/**
|
|
1643
|
-
Enable tracing of the name resolution process.
|
|
1644
|
-
|
|
1645
|
-
@default false
|
|
1646
|
-
*/
|
|
1647
|
-
traceResolution?: boolean;
|
|
1648
|
-
|
|
1649
|
-
/**
|
|
1650
|
-
Allow javascript files to be compiled.
|
|
1651
|
-
|
|
1652
|
-
@default false
|
|
1653
|
-
*/
|
|
1654
|
-
allowJs?: boolean;
|
|
1655
|
-
|
|
1656
|
-
/**
|
|
1657
|
-
Do not truncate error messages.
|
|
1658
|
-
|
|
1659
|
-
@default false
|
|
1660
|
-
*/
|
|
1661
|
-
noErrorTruncation?: boolean;
|
|
1662
|
-
|
|
1663
|
-
/**
|
|
1664
|
-
Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
|
|
1665
|
-
|
|
1666
|
-
@default module === 'system' || esModuleInterop
|
|
1667
|
-
*/
|
|
1668
|
-
allowSyntheticDefaultImports?: boolean;
|
|
1669
|
-
|
|
1670
|
-
/**
|
|
1671
|
-
Do not emit `'use strict'` directives in module output.
|
|
1672
|
-
|
|
1673
|
-
@default false
|
|
1674
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
1675
|
-
*/
|
|
1676
|
-
noImplicitUseStrict?: boolean;
|
|
1677
|
-
|
|
1678
|
-
/**
|
|
1679
|
-
Enable to list all emitted files.
|
|
1680
|
-
|
|
1681
|
-
@default false
|
|
1682
|
-
*/
|
|
1683
|
-
listEmittedFiles?: boolean;
|
|
1684
|
-
|
|
1685
|
-
/**
|
|
1686
|
-
Disable size limit for JavaScript project.
|
|
1687
|
-
|
|
1688
|
-
@default false
|
|
1689
|
-
*/
|
|
1690
|
-
disableSizeLimit?: boolean;
|
|
1691
|
-
|
|
1692
|
-
/**
|
|
1693
|
-
List of library files to be included in the compilation.
|
|
1694
|
-
*/
|
|
1695
|
-
lib?: CompilerOptions.Lib[];
|
|
1696
|
-
|
|
1697
|
-
/**
|
|
1698
|
-
Enable strict null checks.
|
|
1699
|
-
|
|
1700
|
-
@default false
|
|
1701
|
-
*/
|
|
1702
|
-
strictNullChecks?: boolean;
|
|
1703
|
-
|
|
1704
|
-
/**
|
|
1705
|
-
The maximum dependency depth to search under `node_modules` and load JavaScript files. Only applicable with `--allowJs`.
|
|
1706
|
-
|
|
1707
|
-
@default 0
|
|
1708
|
-
*/
|
|
1709
|
-
maxNodeModuleJsDepth?: number;
|
|
1710
|
-
|
|
1711
|
-
/**
|
|
1712
|
-
Import emit helpers (e.g. `__extends`, `__rest`, etc..) from tslib.
|
|
1713
|
-
|
|
1714
|
-
@default false
|
|
1715
|
-
*/
|
|
1716
|
-
importHelpers?: boolean;
|
|
1717
|
-
|
|
1718
|
-
/**
|
|
1719
|
-
Specify emit/checking behavior for imports that are only used for types.
|
|
1720
|
-
|
|
1721
|
-
@default 'remove'
|
|
1722
|
-
@deprecated Use `verbatimModuleSyntax` instead.
|
|
1723
|
-
*/
|
|
1724
|
-
importsNotUsedAsValues?: CompilerOptions.ImportsNotUsedAsValues;
|
|
1725
|
-
|
|
1726
|
-
/**
|
|
1727
|
-
Parse in strict mode and emit `'use strict'` for each source file.
|
|
1728
|
-
|
|
1729
|
-
@default false
|
|
1730
|
-
*/
|
|
1731
|
-
alwaysStrict?: boolean;
|
|
1732
|
-
|
|
1733
|
-
/**
|
|
1734
|
-
Enable all strict type checking options.
|
|
1735
|
-
|
|
1736
|
-
@default false
|
|
1737
|
-
*/
|
|
1738
|
-
strict?: boolean;
|
|
1739
|
-
|
|
1740
|
-
/**
|
|
1741
|
-
Enable stricter checking of of the `bind`, `call`, and `apply` methods on functions.
|
|
1742
|
-
|
|
1743
|
-
@default false
|
|
1744
|
-
*/
|
|
1745
|
-
strictBindCallApply?: boolean;
|
|
1746
|
-
|
|
1747
|
-
/**
|
|
1748
|
-
Provide full support for iterables in `for-of`, spread, and destructuring when targeting `ES5` or `ES3`.
|
|
1749
|
-
|
|
1750
|
-
@default false
|
|
1751
|
-
*/
|
|
1752
|
-
downlevelIteration?: boolean;
|
|
1753
|
-
|
|
1754
|
-
/**
|
|
1755
|
-
Report errors in `.js` files.
|
|
1756
|
-
|
|
1757
|
-
@default false
|
|
1758
|
-
*/
|
|
1759
|
-
checkJs?: boolean;
|
|
1760
|
-
|
|
1761
|
-
/**
|
|
1762
|
-
Built-in iterators are instantiated with a `TReturn` type of undefined instead of `any`.
|
|
1763
|
-
|
|
1764
|
-
@default false
|
|
1765
|
-
*/
|
|
1766
|
-
strictBuiltinIteratorReturn?: boolean;
|
|
1767
|
-
|
|
1768
|
-
/**
|
|
1769
|
-
Disable bivariant parameter checking for function types.
|
|
1770
|
-
|
|
1771
|
-
@default false
|
|
1772
|
-
*/
|
|
1773
|
-
strictFunctionTypes?: boolean;
|
|
1774
|
-
|
|
1775
|
-
/**
|
|
1776
|
-
Ensure non-undefined class properties are initialized in the constructor.
|
|
1777
|
-
|
|
1778
|
-
@default false
|
|
1779
|
-
*/
|
|
1780
|
-
strictPropertyInitialization?: boolean;
|
|
1781
|
-
|
|
1782
|
-
/**
|
|
1783
|
-
Emit `__importStar` and `__importDefault` helpers for runtime Babel ecosystem compatibility and enable `--allowSyntheticDefaultImports` for typesystem compatibility.
|
|
1784
|
-
|
|
1785
|
-
@default false
|
|
1786
|
-
*/
|
|
1787
|
-
esModuleInterop?: boolean;
|
|
1788
|
-
|
|
1789
|
-
/**
|
|
1790
|
-
Allow accessing UMD globals from modules.
|
|
1791
|
-
|
|
1792
|
-
@default false
|
|
1793
|
-
*/
|
|
1794
|
-
allowUmdGlobalAccess?: boolean;
|
|
1795
|
-
|
|
1796
|
-
/**
|
|
1797
|
-
Resolve `keyof` to string valued property names only (no numbers or symbols).
|
|
1798
|
-
|
|
1799
|
-
@default false
|
|
1800
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
1801
|
-
*/
|
|
1802
|
-
keyofStringsOnly?: boolean;
|
|
1803
|
-
|
|
1804
|
-
/**
|
|
1805
|
-
Emit ECMAScript standard class fields.
|
|
1806
|
-
|
|
1807
|
-
@default false
|
|
1808
|
-
*/
|
|
1809
|
-
useDefineForClassFields?: boolean;
|
|
1810
|
-
|
|
1811
|
-
/**
|
|
1812
|
-
Generates a sourcemap for each corresponding `.d.ts` file.
|
|
1813
|
-
|
|
1814
|
-
@default false
|
|
1815
|
-
*/
|
|
1816
|
-
declarationMap?: boolean;
|
|
1817
|
-
|
|
1818
|
-
/**
|
|
1819
|
-
Include modules imported with `.json` extension.
|
|
1820
|
-
|
|
1821
|
-
@default false
|
|
1822
|
-
*/
|
|
1823
|
-
resolveJsonModule?: boolean;
|
|
1824
|
-
|
|
1825
|
-
/**
|
|
1826
|
-
Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.
|
|
1827
|
-
|
|
1828
|
-
@default false
|
|
1829
|
-
*/
|
|
1830
|
-
assumeChangesOnlyAffectDirectDependencies?: boolean;
|
|
1831
|
-
|
|
1832
|
-
/**
|
|
1833
|
-
Output more detailed compiler performance information after building.
|
|
1834
|
-
|
|
1835
|
-
@default false
|
|
1836
|
-
*/
|
|
1837
|
-
extendedDiagnostics?: boolean;
|
|
1838
|
-
|
|
1839
|
-
/**
|
|
1840
|
-
Print names of files that are part of the compilation and then stop processing.
|
|
1841
|
-
|
|
1842
|
-
@default false
|
|
1843
|
-
*/
|
|
1844
|
-
listFilesOnly?: boolean;
|
|
1845
|
-
|
|
1846
|
-
/**
|
|
1847
|
-
Disable preferring source files instead of declaration files when referencing composite projects.
|
|
1848
|
-
|
|
1849
|
-
@default true if composite, false otherwise
|
|
1850
|
-
*/
|
|
1851
|
-
disableSourceOfProjectReferenceRedirect?: boolean;
|
|
1852
|
-
|
|
1853
|
-
/**
|
|
1854
|
-
Opt a project out of multi-project reference checking when editing.
|
|
1855
|
-
|
|
1856
|
-
@default false
|
|
1857
|
-
*/
|
|
1858
|
-
disableSolutionSearching?: boolean;
|
|
1859
|
-
|
|
1860
|
-
/**
|
|
1861
|
-
Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.
|
|
1862
|
-
|
|
1863
|
-
@default false
|
|
1864
|
-
*/
|
|
1865
|
-
explainFiles?: boolean;
|
|
1866
|
-
|
|
1867
|
-
/**
|
|
1868
|
-
Preserve unused imported values in the JavaScript output that would otherwise be removed.
|
|
1869
|
-
|
|
1870
|
-
@default true
|
|
1871
|
-
@deprecated Use `verbatimModuleSyntax` instead.
|
|
1872
|
-
*/
|
|
1873
|
-
preserveValueImports?: boolean;
|
|
1874
|
-
|
|
1875
|
-
/**
|
|
1876
|
-
List of file name suffixes to search when resolving a module.
|
|
1877
|
-
*/
|
|
1878
|
-
moduleSuffixes?: string[];
|
|
1879
|
-
|
|
1880
|
-
/**
|
|
1881
|
-
Control what method is used to detect module-format JS files.
|
|
1882
|
-
|
|
1883
|
-
@default 'auto'
|
|
1884
|
-
*/
|
|
1885
|
-
moduleDetection?: CompilerOptions.ModuleDetection;
|
|
1886
|
-
|
|
1887
|
-
/**
|
|
1888
|
-
Allows TypeScript files to import each other with a TypeScript-specific extension like .ts, .mts, or .tsx.
|
|
1889
|
-
|
|
1890
|
-
@default false
|
|
1891
|
-
*/
|
|
1892
|
-
allowImportingTsExtensions?: boolean;
|
|
1893
|
-
|
|
1894
|
-
/**
|
|
1895
|
-
Forces TypeScript to consult the exports field of package.json files if it ever reads from a package in node_modules.
|
|
1896
|
-
|
|
1897
|
-
@default false
|
|
1898
|
-
*/
|
|
1899
|
-
resolvePackageJsonExports?: boolean;
|
|
1900
|
-
|
|
1901
|
-
/**
|
|
1902
|
-
Forces TypeScript to consult the imports field of package.json files when performing a lookup that starts with # from a file whose ancestor directory contains a package.json.
|
|
1903
|
-
|
|
1904
|
-
@default false
|
|
1905
|
-
*/
|
|
1906
|
-
resolvePackageJsonImports?: boolean;
|
|
1907
|
-
|
|
1908
|
-
/**
|
|
1909
|
-
Suppress errors for file formats that TypeScript does not understand.
|
|
1910
|
-
|
|
1911
|
-
@default false
|
|
1912
|
-
*/
|
|
1913
|
-
allowArbitraryExtensions?: boolean;
|
|
1914
|
-
|
|
1915
|
-
/**
|
|
1916
|
-
List of additional conditions that should succeed when TypeScript resolves from package.json.
|
|
1917
|
-
*/
|
|
1918
|
-
customConditions?: string[];
|
|
1919
|
-
|
|
1920
|
-
/**
|
|
1921
|
-
Anything that uses the type modifier is dropped entirely.
|
|
1922
|
-
|
|
1923
|
-
@default false
|
|
1924
|
-
*/
|
|
1925
|
-
verbatimModuleSyntax?: boolean;
|
|
1926
|
-
|
|
1927
|
-
/**
|
|
1928
|
-
Suppress deprecation warnings
|
|
1929
|
-
*/
|
|
1930
|
-
ignoreDeprecations?: CompilerOptions.IgnoreDeprecations;
|
|
1931
|
-
|
|
1932
|
-
/**
|
|
1933
|
-
Do not allow runtime constructs that are not part of ECMAScript.
|
|
1934
|
-
|
|
1935
|
-
@default false
|
|
1936
|
-
*/
|
|
1937
|
-
erasableSyntaxOnly?: boolean;
|
|
1938
|
-
|
|
1939
|
-
/**
|
|
1940
|
-
Enable lib replacement.
|
|
1941
|
-
|
|
1942
|
-
@default true
|
|
1943
|
-
*/
|
|
1944
|
-
libReplacement?: boolean;
|
|
1945
|
-
};
|
|
1946
|
-
|
|
1947
|
-
namespace WatchOptions {
|
|
1948
|
-
type WatchFileKind =
|
|
1949
|
-
| 'FixedPollingInterval'
|
|
1950
|
-
| 'PriorityPollingInterval'
|
|
1951
|
-
| 'DynamicPriorityPolling'
|
|
1952
|
-
| 'FixedChunkSizePolling'
|
|
1953
|
-
| 'UseFsEvents'
|
|
1954
|
-
| 'UseFsEventsOnParentDirectory';
|
|
1955
|
-
|
|
1956
|
-
type WatchDirectoryKind =
|
|
1957
|
-
| 'UseFsEvents'
|
|
1958
|
-
| 'FixedPollingInterval'
|
|
1959
|
-
| 'DynamicPriorityPolling'
|
|
1960
|
-
| 'FixedChunkSizePolling';
|
|
1961
|
-
|
|
1962
|
-
type PollingWatchKind =
|
|
1963
|
-
| 'FixedInterval'
|
|
1964
|
-
| 'PriorityInterval'
|
|
1965
|
-
| 'DynamicPriority'
|
|
1966
|
-
| 'FixedChunkSize';
|
|
1967
|
-
}
|
|
1968
|
-
|
|
1969
|
-
type WatchOptions = {
|
|
1970
|
-
|
|
1971
|
-
/**
|
|
1972
|
-
Specify the strategy for watching individual files.
|
|
1973
|
-
|
|
1974
|
-
@default 'UseFsEvents'
|
|
1975
|
-
*/
|
|
1976
|
-
watchFile?: WatchOptions.WatchFileKind | Lowercase<WatchOptions.WatchFileKind>;
|
|
1977
|
-
|
|
1978
|
-
/**
|
|
1979
|
-
Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
|
|
1980
|
-
|
|
1981
|
-
@default 'UseFsEvents'
|
|
1982
|
-
*/
|
|
1983
|
-
watchDirectory?: WatchOptions.WatchDirectoryKind | Lowercase<WatchOptions.WatchDirectoryKind>;
|
|
1984
|
-
|
|
1985
|
-
/**
|
|
1986
|
-
Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
|
|
1987
|
-
*/
|
|
1988
|
-
fallbackPolling?: WatchOptions.PollingWatchKind | Lowercase<WatchOptions.PollingWatchKind>;
|
|
1989
|
-
|
|
1990
|
-
/**
|
|
1991
|
-
Enable synchronous updates on directory watchers for platforms that don't support recursive watching natively.
|
|
1992
|
-
*/
|
|
1993
|
-
synchronousWatchDirectory?: boolean;
|
|
1994
|
-
|
|
1995
|
-
/**
|
|
1996
|
-
Specifies a list of directories to exclude from watch.
|
|
1997
|
-
*/
|
|
1998
|
-
excludeDirectories?: string[];
|
|
1999
|
-
|
|
2000
|
-
/**
|
|
2001
|
-
Specifies a list of files to exclude from watch.
|
|
2002
|
-
*/
|
|
2003
|
-
excludeFiles?: string[];
|
|
2004
|
-
};
|
|
2005
|
-
|
|
2006
|
-
/**
|
|
2007
|
-
Auto type (.d.ts) acquisition options for this project.
|
|
2008
|
-
*/
|
|
2009
|
-
type TypeAcquisition = {
|
|
2010
|
-
/**
|
|
2011
|
-
Enable auto type acquisition.
|
|
2012
|
-
*/
|
|
2013
|
-
enable?: boolean;
|
|
2014
|
-
|
|
2015
|
-
/**
|
|
2016
|
-
Specifies a list of type declarations to be included in auto type acquisition. For example, `['jquery', 'lodash']`.
|
|
2017
|
-
*/
|
|
2018
|
-
include?: string[];
|
|
2019
|
-
|
|
2020
|
-
/**
|
|
2021
|
-
Specifies a list of type declarations to be excluded from auto type acquisition. For example, `['jquery', 'lodash']`.
|
|
2022
|
-
*/
|
|
2023
|
-
exclude?: string[];
|
|
2024
|
-
|
|
2025
|
-
/**
|
|
2026
|
-
Disable infering what types should be added based on filenames in a project.
|
|
2027
|
-
*/
|
|
2028
|
-
disableFilenameBasedTypeAcquisition?: boolean;
|
|
2029
|
-
};
|
|
2030
|
-
|
|
2031
|
-
type References = {
|
|
2032
|
-
/**
|
|
2033
|
-
A normalized path on disk.
|
|
2034
|
-
*/
|
|
2035
|
-
path: string;
|
|
2036
|
-
|
|
2037
|
-
/**
|
|
2038
|
-
The path as the user originally wrote it.
|
|
2039
|
-
*/
|
|
2040
|
-
originalPath?: string;
|
|
2041
|
-
|
|
2042
|
-
/**
|
|
2043
|
-
True if the output of this reference should be prepended to the output of this project.
|
|
2044
|
-
|
|
2045
|
-
Only valid for `--outFile` compilations.
|
|
2046
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
2047
|
-
*/
|
|
2048
|
-
prepend?: boolean;
|
|
2049
|
-
|
|
2050
|
-
/**
|
|
2051
|
-
True if it is intended that this reference form a circularity.
|
|
2052
|
-
*/
|
|
2053
|
-
circular?: boolean;
|
|
2054
|
-
};
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2057
|
-
/**
|
|
2058
|
-
Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) (TypeScript 3.7).
|
|
2059
|
-
|
|
2060
|
-
@category File
|
|
2061
|
-
*/
|
|
2062
|
-
type TsConfigJson = {
|
|
2063
|
-
/**
|
|
2064
|
-
Instructs the TypeScript compiler how to compile `.ts` files.
|
|
2065
|
-
*/
|
|
2066
|
-
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
2067
|
-
|
|
2068
|
-
/**
|
|
2069
|
-
Instructs the TypeScript compiler how to watch files.
|
|
2070
|
-
*/
|
|
2071
|
-
watchOptions?: TsConfigJson.WatchOptions;
|
|
2072
|
-
|
|
2073
|
-
/**
|
|
2074
|
-
Auto type (.d.ts) acquisition options for this project.
|
|
2075
|
-
*/
|
|
2076
|
-
typeAcquisition?: TsConfigJson.TypeAcquisition;
|
|
2077
|
-
|
|
2078
|
-
/**
|
|
2079
|
-
Enable Compile-on-Save for this project.
|
|
2080
|
-
*/
|
|
2081
|
-
compileOnSave?: boolean;
|
|
2082
|
-
|
|
2083
|
-
/**
|
|
2084
|
-
Path to base configuration file to inherit from.
|
|
2085
|
-
*/
|
|
2086
|
-
extends?: string | string[];
|
|
2087
|
-
|
|
2088
|
-
/**
|
|
2089
|
-
If no `files` or `include` property is present in a `tsconfig.json`, the compiler defaults to including all files in the containing directory and subdirectories except those specified by `exclude`. When a `files` property is specified, only those files and those specified by `include` are included.
|
|
2090
|
-
*/
|
|
2091
|
-
files?: string[];
|
|
2092
|
-
|
|
2093
|
-
/**
|
|
2094
|
-
Specifies a list of files to be excluded from compilation. The `exclude` property only affects the files included via the `include` property and not the `files` property.
|
|
2095
|
-
|
|
2096
|
-
Glob patterns require TypeScript version 2.0 or later.
|
|
2097
|
-
*/
|
|
2098
|
-
exclude?: string[];
|
|
5
|
+
Create a type that represents either the value or an array of the value.
|
|
2099
6
|
|
|
2100
|
-
|
|
2101
|
-
Specifies a list of glob patterns that match files to be included in compilation.
|
|
7
|
+
@see {@link Promisable}
|
|
2102
8
|
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
9
|
+
@example
|
|
10
|
+
```
|
|
11
|
+
import type {Arrayable} from 'type-fest';
|
|
2106
12
|
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
*/
|
|
2110
|
-
references?: TsConfigJson.References[];
|
|
2111
|
-
};
|
|
13
|
+
function bundle(input: string, output: Arrayable<string>) {
|
|
14
|
+
const outputList = Array.isArray(output) ? output : [output];
|
|
2112
15
|
|
|
2113
|
-
|
|
2114
|
-
/**
|
|
2115
|
-
* Base class providing view functionality over a target object using the Composition pattern.
|
|
2116
|
-
*/
|
|
2117
|
-
declare class View<Target extends object> implements IView<Target> {
|
|
2118
|
-
private [TARGET_SYMBOL];
|
|
2119
|
-
constructor(target: Target);
|
|
2120
|
-
get [Symbol.toStringTag](): string;
|
|
2121
|
-
get target(): Target;
|
|
2122
|
-
}
|
|
16
|
+
// …
|
|
2123
17
|
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
keys?: (string | symbol)[];
|
|
2128
|
-
autoAddBooleanKeys?: boolean;
|
|
2129
|
-
ignoreKeys?: (string | symbol)[];
|
|
2130
|
-
filters?: InspectFilter[];
|
|
2131
|
-
}
|
|
2132
|
-
interface IgnoreValuesOptions {
|
|
2133
|
-
noEmptyArray?: boolean;
|
|
2134
|
-
noEmptyObject?: boolean;
|
|
2135
|
-
noNull?: boolean;
|
|
2136
|
-
noUndefined?: boolean;
|
|
2137
|
-
noFalse?: boolean;
|
|
18
|
+
for (const output of outputList) {
|
|
19
|
+
console.log(`write ${input} to: ${output}`);
|
|
20
|
+
}
|
|
2138
21
|
}
|
|
2139
|
-
type InspectFilter = <T extends InspectorTarget>(this: T, value: unknown, key: string | symbol, depth: number, object: T) => boolean;
|
|
2140
|
-
type ClassInspectorMixin = typeof Function.prototype & {
|
|
2141
|
-
inspector: InspectorOptions;
|
|
2142
|
-
};
|
|
2143
22
|
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
*/
|
|
2148
|
-
interface InspectorTarget {
|
|
2149
|
-
[inspect.custom](depth: number, options: InspectOptions): string;
|
|
2150
|
-
get inspector(): Inspector;
|
|
2151
|
-
toJSON(): Partial<this>;
|
|
2152
|
-
}
|
|
2153
|
-
/**
|
|
2154
|
-
* Inspector provides customizable object inspection and serialization using the Composition pattern.
|
|
2155
|
-
* Composes target classes with inspection capabilities, allowing selective property display and custom formatting.
|
|
2156
|
-
*/
|
|
2157
|
-
declare class Inspector extends View<InspectorTarget> {
|
|
2158
|
-
/**
|
|
2159
|
-
* Composes a class with Inspector capabilities by adding inspection methods to its prototype.
|
|
2160
|
-
* This follows the Composition pattern to extend classes without inheritance.
|
|
2161
|
-
*/
|
|
2162
|
-
static compose(cls: ClassInspectorMixin, options?: InspectorOptions): InspectorOptions;
|
|
2163
|
-
/**
|
|
2164
|
-
* Compile the target object and return the output as an object.
|
|
2165
|
-
*/
|
|
2166
|
-
toObject(depth?: number): Partial<InspectorTarget>;
|
|
2167
|
-
/**
|
|
2168
|
-
* Inspect the target object.
|
|
2169
|
-
*/
|
|
2170
|
-
inspect(depth?: number, options?: InspectOptions): string;
|
|
2171
|
-
/**
|
|
2172
|
-
* Compiles the output object and inspect options.
|
|
2173
|
-
* Merges prototype chain options and applies filters to determine which properties to include.
|
|
2174
|
-
*/
|
|
2175
|
-
protected compile(depth?: number): {
|
|
2176
|
-
output: Partial<InspectorTarget>;
|
|
2177
|
-
inspectOptions: InspectOptions;
|
|
2178
|
-
};
|
|
2179
|
-
/**
|
|
2180
|
-
* Walks the prototype chain and merges Inspector options from all classes.
|
|
2181
|
-
* Subclass options override superclass options following inheritance semantics.
|
|
2182
|
-
*/
|
|
2183
|
-
protected mergePrototypeOptions(): Required<InspectorOptions>;
|
|
2184
|
-
/**
|
|
2185
|
-
* Returns a deep clone of the default Inspector options.
|
|
2186
|
-
*/
|
|
2187
|
-
protected getDefaults(): Required<InspectorOptions>;
|
|
2188
|
-
}
|
|
23
|
+
bundle('src/index.js', 'dist/index.js');
|
|
24
|
+
bundle('src/index.js', ['dist/index.cjs', 'dist/index.mjs']);
|
|
25
|
+
```
|
|
2189
26
|
|
|
2190
|
-
|
|
27
|
+
@category Array
|
|
28
|
+
*/
|
|
29
|
+
type Arrayable<T> =
|
|
30
|
+
T
|
|
31
|
+
// TODO: Use `readonly T[]` when this issue is resolved: https://github.com/microsoft/TypeScript/issues/17002
|
|
32
|
+
| T[];
|
|
2191
33
|
|
|
2192
34
|
interface PackageJson {
|
|
2193
35
|
name?: string;
|
|
@@ -2246,389 +88,380 @@ interface PackageJson {
|
|
|
2246
88
|
}
|
|
2247
89
|
|
|
2248
90
|
/**
|
|
2249
|
-
*
|
|
2250
|
-
*
|
|
2251
|
-
* In order to avoid circular references, all children keep a weak reference to their parent. However,
|
|
2252
|
-
* it is not guaranteed. Two objects could in principle mutually be both each other's parent and child
|
|
2253
|
-
* at the same time which would allow circular references to exist.
|
|
91
|
+
* A workspace of the monorepo: a directory with a package.json that is matched by the root package.json's
|
|
92
|
+
* 'workspaces' patterns. Plain data, created by `readWorkspace` or `getWorkspaces`.
|
|
2254
93
|
*/
|
|
2255
|
-
|
|
2256
|
-
/**
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
/**
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
/**
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
94
|
+
interface Workspace {
|
|
95
|
+
/** The package name from the workspace's package.json. */
|
|
96
|
+
name: string;
|
|
97
|
+
/** Absolute path of the workspace directory, with forward slashes. */
|
|
98
|
+
path: string;
|
|
99
|
+
/** Path of the workspace directory relative to the repo root, e.g. 'libs/string'. */
|
|
100
|
+
relativePath: string;
|
|
101
|
+
/** Name of the directory that contains the workspace, e.g. 'libs' or 'apps'. */
|
|
102
|
+
origin: string;
|
|
103
|
+
/** The parsed package.json of the workspace. */
|
|
104
|
+
packageJson: PackageJson;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* What a dependency points at, seen from the module that imports it.
|
|
109
|
+
* - `local`: a file in the same workspace
|
|
110
|
+
* - `workspace`: a file in another workspace of the repo
|
|
111
|
+
* - `external`: a package in node_modules
|
|
112
|
+
* - `builtin`: a node built-in module
|
|
113
|
+
* - `unresolved`: could not be resolved to a file
|
|
114
|
+
*/
|
|
115
|
+
type DependencyKind = 'local' | 'workspace' | 'external' | 'builtin' | 'unresolved';
|
|
116
|
+
/**
|
|
117
|
+
* A single import (or re-export, require etc.) of one module by another.
|
|
118
|
+
*/
|
|
119
|
+
interface GraphDependency {
|
|
2276
120
|
/**
|
|
2277
|
-
* The
|
|
121
|
+
* The module specifier as written in the code, e.g. './foo' or 'es-toolkit/array'.
|
|
122
|
+
* A node built-in is given without its 'node:' prefix.
|
|
2278
123
|
*/
|
|
2279
|
-
|
|
124
|
+
specifier: string;
|
|
125
|
+
/** The resolved file path relative to the repo root. For builtin and unresolved dependencies: the specifier. */
|
|
126
|
+
resolved: string;
|
|
127
|
+
/** What the dependency points at. */
|
|
128
|
+
kind: DependencyKind;
|
|
2280
129
|
/**
|
|
2281
|
-
*
|
|
130
|
+
* The name of what is depended on: the package name for `external`, the workspace's package name for
|
|
131
|
+
* `workspace` and the module name without 'node:' prefix for `builtin`. Undefined for `local` and `unresolved`.
|
|
2282
132
|
*/
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
133
|
+
name?: string;
|
|
134
|
+
/** Whether it is imported with the `type` keyword only. */
|
|
135
|
+
typeOnly: boolean;
|
|
136
|
+
/** Whether the dependency is part of a circular chain of dependencies. */
|
|
137
|
+
circular: boolean;
|
|
2288
138
|
}
|
|
2289
|
-
type ParentingTargetConstructor<P extends object | null = object | null> = {
|
|
2290
|
-
parenting?: ParentRelationTypes<P>;
|
|
2291
|
-
} & typeof Function.prototype;
|
|
2292
|
-
|
|
2293
139
|
/**
|
|
2294
|
-
*
|
|
140
|
+
* A file of the repo in the dependency graph.
|
|
2295
141
|
*/
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
get isLeaf(): boolean;
|
|
2304
|
-
get isIsolated(): boolean;
|
|
2305
|
-
static getAllChildTypesStats(): Record<string, Record<string, number>>;
|
|
2306
|
-
static getAllParentTypesStats(): Record<string, Record<string, number>>;
|
|
2307
|
-
static getAllStats(): any[];
|
|
2308
|
-
static printAllStats(): void;
|
|
2309
|
-
static childTypesStats: DefaultMap<Function, MultiSet<Function>>;
|
|
2310
|
-
static parentTypesStats: DefaultMap<Function, MultiSet<Function>>;
|
|
2311
|
-
}
|
|
2312
|
-
|
|
2313
|
-
declare module './AbstractBase' {
|
|
2314
|
-
interface AbstractBase extends InspectorTarget {
|
|
2315
|
-
}
|
|
2316
|
-
interface AbstractBase<P extends object | null> extends ParentingTarget<P> {
|
|
2317
|
-
}
|
|
142
|
+
interface GraphModule {
|
|
143
|
+
/** The file path relative to the repo root, with forward slashes. */
|
|
144
|
+
path: string;
|
|
145
|
+
/** The workspace the file belongs to, if any. */
|
|
146
|
+
workspace?: Workspace;
|
|
147
|
+
/** Everything the file imports. */
|
|
148
|
+
dependencies: GraphDependency[];
|
|
2318
149
|
}
|
|
2319
150
|
/**
|
|
2320
|
-
*
|
|
151
|
+
* The files of the repo and what they import. Created by `createDependencyGraph`.
|
|
2321
152
|
*/
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
153
|
+
interface DependencyGraph {
|
|
154
|
+
/** Absolute path of the repo root, with forward slashes. */
|
|
155
|
+
root: string;
|
|
156
|
+
/** The workspaces of the repo. */
|
|
157
|
+
workspaces: Workspace[];
|
|
158
|
+
/** The files of the repo that were analyzed, by their path relative to the repo root. */
|
|
159
|
+
modules: Map<string, GraphModule>;
|
|
2328
160
|
}
|
|
2329
161
|
|
|
2330
162
|
/**
|
|
2331
|
-
*
|
|
163
|
+
* Options of `createDependencyGraph`.
|
|
2332
164
|
*/
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
index: number;
|
|
2347
|
-
lastIndex: number;
|
|
2348
|
-
};
|
|
2349
|
-
getCodeRange(range: {
|
|
2350
|
-
index: number;
|
|
2351
|
-
lastIndex: number;
|
|
2352
|
-
}): string;
|
|
165
|
+
interface CreateDependencyGraphOptions {
|
|
166
|
+
/** The repo root. Defaults to the root of the repo that contains the current working directory. */
|
|
167
|
+
root?: string;
|
|
168
|
+
/**
|
|
169
|
+
* The files and directories to start from. Relative paths are resolved against the repo root.
|
|
170
|
+
* Everything they import is followed, also into other workspaces. Defaults to the 'src' directory of every
|
|
171
|
+
* workspace.
|
|
172
|
+
*/
|
|
173
|
+
entries?: string[];
|
|
174
|
+
/** Whether to include test files (*.test.*). Defaults to false. */
|
|
175
|
+
includeTests?: boolean;
|
|
176
|
+
/** The workspaces of the repo. Defaults to `getWorkspaces(root)`. */
|
|
177
|
+
workspaces?: Workspace[];
|
|
2353
178
|
}
|
|
2354
|
-
|
|
2355
179
|
/**
|
|
2356
|
-
*
|
|
180
|
+
* Analyzes which files import what, using dependency-cruiser, and returns it as a graph of plain data.
|
|
181
|
+
*
|
|
182
|
+
* Imports are resolved the same way the repo's TypeScript code is: with the 'paths' of the tsconfig.json in the
|
|
183
|
+
* repo root and the 'exports' of package.json files. Files with a semantic extname prefix (examples, benchmarks,
|
|
184
|
+
* declarations etc.) are left out, and so are test files unless `includeTests` is set. Packages in node_modules
|
|
185
|
+
* are not followed.
|
|
186
|
+
*
|
|
187
|
+
* Analyzing a whole repo takes around a second, so create the graph once and pass it to the functions that
|
|
188
|
+
* read from it.
|
|
2357
189
|
*/
|
|
2358
|
-
declare
|
|
2359
|
-
static readonly inspector: InspectorOptions;
|
|
2360
|
-
readonly indexRange: {
|
|
2361
|
-
index: number;
|
|
2362
|
-
lastIndex: number;
|
|
2363
|
-
};
|
|
2364
|
-
constructor(parent: P, indexRange: {
|
|
2365
|
-
index: number;
|
|
2366
|
-
lastIndex: number;
|
|
2367
|
-
});
|
|
2368
|
-
toString(): string;
|
|
2369
|
-
}
|
|
190
|
+
declare function createDependencyGraph(options?: CreateDependencyGraphOptions): Promise<DependencyGraph>;
|
|
2370
191
|
|
|
2371
192
|
/**
|
|
2372
|
-
*
|
|
193
|
+
* Returns the package name part of a module specifier.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* getDependencyName('es-toolkit/array') // 'es-toolkit'
|
|
198
|
+
* getDependencyName('@mono/string/camelCase') // '@mono/string'
|
|
199
|
+
* ```
|
|
2373
200
|
*/
|
|
2374
|
-
declare
|
|
2375
|
-
static readonly inspector: InspectorOptions;
|
|
2376
|
-
get keywords(): string[];
|
|
2377
|
-
has(kw: string): boolean;
|
|
2378
|
-
get isType(): boolean;
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2381
|
-
declare class ImportSpecifiers<P extends ImportStatement = ImportStatement> extends CodeBlock<P> {
|
|
2382
|
-
static readonly inspector: InspectorOptions;
|
|
2383
|
-
get codeWithoutTypeKeyword(): string;
|
|
2384
|
-
get type(): 'default' | 'named' | 'mixed' | 'namespace';
|
|
2385
|
-
get isDefaultImport(): boolean;
|
|
2386
|
-
get isNamedImport(): boolean;
|
|
2387
|
-
get isMixedImport(): boolean;
|
|
2388
|
-
get isNamespaceImport(): boolean;
|
|
2389
|
-
get namedImportsArray(): string[];
|
|
2390
|
-
/**
|
|
2391
|
-
* Splits the import specifier into an array of specifiers as if to split into individual import statements.
|
|
2392
|
-
* @example `{A,B} => {A},{B}`
|
|
2393
|
-
*/
|
|
2394
|
-
splitSpecifiers(): string[];
|
|
2395
|
-
/**
|
|
2396
|
-
* Returns the keys added to the global namespace by this import specifier.
|
|
2397
|
-
*/
|
|
2398
|
-
get importedNamesArray(): string[];
|
|
2399
|
-
get defaultImport(): string | undefined;
|
|
2400
|
-
get namespaceImport(): string | undefined;
|
|
2401
|
-
get hasNamedImport(): boolean;
|
|
2402
|
-
get hasDefaultImport(): boolean;
|
|
2403
|
-
}
|
|
201
|
+
declare function getDependencyName(moduleSpecifier: string): string;
|
|
2404
202
|
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
/**
|
|
2416
|
-
* Returns whether import is an other, but local workspace in the monorepo.
|
|
2417
|
-
*/
|
|
2418
|
-
get isOtherRepoWorkspace(): boolean;
|
|
2419
|
-
get isRelative(): boolean;
|
|
2420
|
-
get isFromRepoRoot(): boolean;
|
|
2421
|
-
get isExternal(): boolean;
|
|
2422
|
-
get isDependency(): boolean;
|
|
2423
|
-
}
|
|
203
|
+
/**
|
|
204
|
+
* Maps every package the given modules import to a caret range of its installed version, ready to be put in the
|
|
205
|
+
* 'dependencies' of a package.json. Sorted by package name.
|
|
206
|
+
*
|
|
207
|
+
* If a package ships no types of its own and its `@types/` package is installed, that is included too.
|
|
208
|
+
*
|
|
209
|
+
* @param modules - Modules of a dependency graph.
|
|
210
|
+
* @param root - The repo root: the `root` of the dependency graph.
|
|
211
|
+
*/
|
|
212
|
+
declare function getExternalDependencyVersions(modules: GraphModule[], root: string): Record<string, string>;
|
|
2424
213
|
|
|
2425
214
|
/**
|
|
2426
|
-
*
|
|
215
|
+
* What a set of files depends on.
|
|
2427
216
|
*/
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
get filepath(): string;
|
|
217
|
+
interface ImportedDependencies {
|
|
218
|
+
/** Packages in node_modules, mapped to a caret range of the installed version. */
|
|
219
|
+
external: Record<string, string>;
|
|
220
|
+
/** Node built-in modules, without the 'node:' prefix. */
|
|
221
|
+
builtin: string[];
|
|
222
|
+
/** Package names of other workspaces of the repo. */
|
|
223
|
+
internal: string[];
|
|
2436
224
|
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
get isDeclaration(): boolean;
|
|
2448
|
-
get isTest(): boolean;
|
|
2449
|
-
get isIndexFile(): boolean;
|
|
2450
|
-
get isSourceFile(): boolean;
|
|
2451
|
-
/**
|
|
2452
|
-
* Read the file contents.
|
|
2453
|
-
*/
|
|
2454
|
-
protected readFile(): string;
|
|
225
|
+
/**
|
|
226
|
+
* The result of `getImportsRecursively`.
|
|
227
|
+
*/
|
|
228
|
+
interface ImportsRecursivelyResult {
|
|
229
|
+
/** Every file that is reached from the entry points, in the order of discovery. Relative to the repo root. */
|
|
230
|
+
filepaths: string[];
|
|
231
|
+
/** What all the reached files depend on, including the files in other workspaces. */
|
|
232
|
+
recursive: ImportedDependencies;
|
|
233
|
+
/** What the reached files in the workspace of the entry points depend on. */
|
|
234
|
+
local: ImportedDependencies;
|
|
2455
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Follows the imports of the given entry points through the repo and lists what is depended on along the way.
|
|
238
|
+
*
|
|
239
|
+
* @param entryPoints - Files of a single workspace. Relative paths are resolved against the repo root.
|
|
240
|
+
* @param options.root - The repo root. Defaults to the root of the repo that contains the current working directory.
|
|
241
|
+
* @param options.graph - A dependency graph to read from. By default one is created from the entry points.
|
|
242
|
+
* @throws If the entry points are not all in the same workspace, or if an import cannot be resolved.
|
|
243
|
+
*/
|
|
244
|
+
declare function getImportsRecursively(entryPoints: string[], options?: {
|
|
245
|
+
root?: string;
|
|
246
|
+
graph?: DependencyGraph;
|
|
247
|
+
}): Promise<ImportsRecursivelyResult>;
|
|
2456
248
|
|
|
2457
249
|
/**
|
|
2458
|
-
*
|
|
250
|
+
* Returns the given modules and every module they import, directly or through other modules, in the order they
|
|
251
|
+
* are discovered. Each module is returned once.
|
|
252
|
+
*
|
|
253
|
+
* @param graph - The dependency graph.
|
|
254
|
+
* @param entries - The paths of the modules to start from, relative to the repo root.
|
|
255
|
+
* @param follow - The kinds of dependency to follow. Defaults to both `local` and `workspace`. Pass `['local']`
|
|
256
|
+
* to stay within the workspaces of the entries.
|
|
2459
257
|
*/
|
|
2460
|
-
declare
|
|
2461
|
-
static readonly inspector: InspectorOptions;
|
|
2462
|
-
get tsCode(): TsCode;
|
|
2463
|
-
get dependencies(): string[];
|
|
2464
|
-
}
|
|
258
|
+
declare function getReachableModules(graph: DependencyGraph, entries: string[], follow?: DependencyKind[]): GraphModule[];
|
|
2465
259
|
|
|
2466
260
|
/**
|
|
2467
|
-
*
|
|
261
|
+
* The names of what a set of modules depends on, each sorted and without duplicates.
|
|
2468
262
|
*/
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
get imports(): ImportStatement[];
|
|
2477
|
-
get exportedClassNames(): string[];
|
|
2478
|
-
get dependencies(): string[];
|
|
2479
|
-
private get requireRegex();
|
|
263
|
+
interface DependencySummary {
|
|
264
|
+
/** Node built-in modules, without the 'node:' prefix. */
|
|
265
|
+
builtin: string[];
|
|
266
|
+
/** Package names of dependencies in node_modules. */
|
|
267
|
+
external: string[];
|
|
268
|
+
/** Package names of other workspaces of the repo. */
|
|
269
|
+
internal: string[];
|
|
2480
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Lists the names of everything the given modules import directly, grouped by kind.
|
|
273
|
+
*/
|
|
274
|
+
declare function summarizeDependencies(modules: GraphModule[]): DependencySummary;
|
|
2481
275
|
|
|
2482
276
|
/**
|
|
2483
|
-
*
|
|
277
|
+
* Lists what the source files of a workspace depend on: node built-ins, packages and other workspaces.
|
|
278
|
+
* Test files are not counted.
|
|
279
|
+
*
|
|
280
|
+
* @param workspace - The workspace.
|
|
281
|
+
* @param graph - A dependency graph that covers the workspace, see `createDependencyGraph`.
|
|
282
|
+
* @param options.recursive - Whether to also count what the imported files of other workspaces depend on,
|
|
283
|
+
* and so on. Defaults to false: only what the workspace's own files import.
|
|
2484
284
|
*/
|
|
2485
|
-
declare
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
get dependencies(): string[];
|
|
2489
|
-
}
|
|
285
|
+
declare function getWorkspaceDependencies(workspace: Workspace, graph: DependencyGraph, options?: {
|
|
286
|
+
recursive?: boolean;
|
|
287
|
+
}): DependencySummary;
|
|
2490
288
|
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
* The workspace's origin directory name, eg. 'libs', 'apps', etc.
|
|
2495
|
-
*/
|
|
2496
|
-
readonly origin: string;
|
|
2497
|
-
/**
|
|
2498
|
-
* The workspace's root directory path.
|
|
2499
|
-
*/
|
|
2500
|
-
readonly path: string;
|
|
2501
|
-
constructor(parent: P, dirpath: string);
|
|
2502
|
-
/**
|
|
2503
|
-
* The workspace's package.json filepath.
|
|
2504
|
-
*/
|
|
2505
|
-
get packageJsonPath(): string;
|
|
2506
|
-
/**
|
|
2507
|
-
* The workspace's package.json file as an object.
|
|
2508
|
-
*/
|
|
2509
|
-
get packageJson(): PackageJson;
|
|
2510
|
-
/**
|
|
2511
|
-
* The workspace's name from the package.json file.
|
|
2512
|
-
*/
|
|
2513
|
-
get name(): string;
|
|
2514
|
-
/**
|
|
2515
|
-
* Reads the workspace's package.json file and returns the 'dependencies' field as a sorted array of strings.
|
|
2516
|
-
*/
|
|
2517
|
-
get installedDependencies(): string[];
|
|
2518
|
-
/**
|
|
2519
|
-
* Reads the workspace's package.json file and returns the 'devDependencies' field as a sorted array of strings.
|
|
2520
|
-
*/
|
|
2521
|
-
get installedDevDependencies(): string[];
|
|
2522
|
-
/**
|
|
2523
|
-
* Get all unique file-level dependencies of the workspace, including transitive dependencies through other local workspaces.
|
|
2524
|
-
*
|
|
2525
|
-
* This method recursively traverses the dependency graph of the workspace, collecting all unique dependencies. It distinguishes between internal dependencies (other local workspaces) and external dependencies (npm packages).
|
|
2526
|
-
*
|
|
2527
|
-
* @returns An object containing two arrays: `internal` for internal workspace dependencies and `external` for npm package dependencies.
|
|
2528
|
-
*/
|
|
2529
|
-
get importedDependenciesRecursive(): {
|
|
2530
|
-
internal: string[];
|
|
2531
|
-
external: string[];
|
|
2532
|
-
};
|
|
2533
|
-
/**
|
|
2534
|
-
* Get the source files in the workspace's 'src' directory.
|
|
2535
|
-
* Test files are not included.
|
|
2536
|
-
*/
|
|
2537
|
-
get tsFiles(): TsFile[];
|
|
2538
|
-
/**
|
|
2539
|
-
* Get the test files in the workspace's 'src' directory.
|
|
2540
|
-
*/
|
|
2541
|
-
get testFiles(): TsFile[];
|
|
2542
|
-
get files(): (TsFile | TestFile)[];
|
|
2543
|
-
/**
|
|
2544
|
-
* Get imported non-relative dependencies for each source file in the workspace, grouped by file.
|
|
2545
|
-
*/
|
|
2546
|
-
get importedDependenciesByFile(): Map<string, string[]>;
|
|
2547
|
-
/**
|
|
2548
|
-
* Get imported non-relative dependencies for each test file in the workspace, grouped by file.
|
|
2549
|
-
*/
|
|
2550
|
-
get importedTestDependenciesByFile(): Map<string, string[]>;
|
|
2551
|
-
/**
|
|
2552
|
-
* Get imported non-relative dependencies for each source file in the workspace in a flat array.
|
|
2553
|
-
*/
|
|
2554
|
-
get importedDependencies(): string[];
|
|
2555
|
-
/**
|
|
2556
|
-
* Get imported non-relative dependencies for each test file in the workspace in a flat array.
|
|
2557
|
-
*/
|
|
2558
|
-
get importedTestDependencies(): string[];
|
|
2559
|
-
/**
|
|
2560
|
-
* Get dependencies that are imported but not listed in the workspace's package.json under 'dependencies'.
|
|
2561
|
-
*/
|
|
2562
|
-
get missingDependencies(): string[];
|
|
2563
|
-
/**
|
|
2564
|
-
* Get dependencies that are imported but not listed in the workspace's package.json under 'devDependencies'.
|
|
2565
|
-
*/
|
|
2566
|
-
get missingDevDependencies(): string[];
|
|
2567
|
-
/**
|
|
2568
|
-
* Get dependencies that are listed in the workspace's package.json but not imported in any source file (excl. test files).
|
|
2569
|
-
*/
|
|
2570
|
-
get unusedDependencies(): string[];
|
|
2571
|
-
/**
|
|
2572
|
-
*
|
|
2573
|
-
*/
|
|
2574
|
-
get incorrectlyImportedRepoWorkspaces(): IncorrectlyImportedRepoWorkspace[];
|
|
2575
|
-
/**
|
|
2576
|
-
* Returns an object with found dependency problems for the workspace or undefined if no problems were found.
|
|
2577
|
-
* @see WorkspaceDependencyProblems
|
|
2578
|
-
*/
|
|
2579
|
-
get dependencyProblems(): WorkspaceDependencyProblems | undefined;
|
|
2580
|
-
depcheck(): Promise<Results>;
|
|
2581
|
-
/**
|
|
2582
|
-
* Returns the workspace's cwd-relative path.
|
|
2583
|
-
*/
|
|
2584
|
-
toString(): string;
|
|
2585
|
-
}
|
|
289
|
+
/**
|
|
290
|
+
* The dependency problems of a workspace. A property is left out if there is nothing to report for it.
|
|
291
|
+
*/
|
|
2586
292
|
interface WorkspaceDependencyProblems {
|
|
293
|
+
/** Name of the directory that contains the workspace, e.g. 'libs' or 'apps'. */
|
|
2587
294
|
origin: string;
|
|
295
|
+
/** The package name of the workspace. */
|
|
2588
296
|
workspace: string;
|
|
297
|
+
/** Listed in the 'dependencies' of the workspace's package.json, but not imported by any source file. */
|
|
2589
298
|
unused?: string[];
|
|
299
|
+
/** Imported by a source file, but not listed in the 'dependencies' of the workspace's package.json. */
|
|
2590
300
|
missing?: string[];
|
|
301
|
+
/** Imported by a test file, but not listed in the workspace's 'dependencies' or 'devDependencies'. */
|
|
2591
302
|
missingDev?: string[];
|
|
2592
|
-
imports?: IncorrectlyImportedRepoWorkspace[];
|
|
2593
303
|
}
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
304
|
+
/**
|
|
305
|
+
* Compares what the files of a workspace import with what its package.json lists, and returns what does not add
|
|
306
|
+
* up. Returns undefined if there are no problems.
|
|
307
|
+
*
|
|
308
|
+
* A dependency is not reported as missing if the root package.json lists it, or if it is one of the 'paths' in
|
|
309
|
+
* the tsconfig.paths.json of the repo root.
|
|
310
|
+
*
|
|
311
|
+
* @param workspace - The workspace.
|
|
312
|
+
* @param graph - A dependency graph that covers the workspace, see `createDependencyGraph`. Create it with
|
|
313
|
+
* `includeTests` for `missingDev` to be checked.
|
|
314
|
+
*/
|
|
315
|
+
declare function getWorkspaceDependencyProblems(workspace: Workspace, graph: DependencyGraph): WorkspaceDependencyProblems | undefined;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Returns the modules of the dependency graph that belong to the given workspace.
|
|
319
|
+
*/
|
|
320
|
+
declare function getWorkspaceModules(workspace: Workspace, graph: DependencyGraph): GraphModule[];
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The type of path used in an import statement.
|
|
324
|
+
*/
|
|
325
|
+
type ImportPathType = 'relative' | 'absolute' | 'builtin' | 'package' | 'workspace';
|
|
326
|
+
/**
|
|
327
|
+
* The type of import specifier.
|
|
328
|
+
*/
|
|
329
|
+
type ImportSpecifierType = 'default' | 'namespace' | 'named';
|
|
330
|
+
/**
|
|
331
|
+
* The overall type of import statement based on its specifiers.
|
|
332
|
+
*/
|
|
333
|
+
type ImportStatementType = 'default' | 'namespace' | 'named' | 'sideEffect' | 'mixed';
|
|
334
|
+
/**
|
|
335
|
+
* Represents the keywords portion of an import statement (e.g., 'import type').
|
|
336
|
+
*/
|
|
337
|
+
interface ImportKeywords {
|
|
338
|
+
/** The raw code containing the keywords */
|
|
339
|
+
code: string;
|
|
340
|
+
/** Array of individual keywords */
|
|
341
|
+
keywords: string[];
|
|
342
|
+
/** Whether the 'type' keyword is present */
|
|
343
|
+
hasTypeKeyword: boolean;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Represents a single import specifier (e.g., a named import, default import, etc.).
|
|
347
|
+
*/
|
|
348
|
+
interface ImportSpecifier {
|
|
349
|
+
/** The raw code for this specifier */
|
|
350
|
+
code: string;
|
|
351
|
+
/** The type of this specifier */
|
|
352
|
+
type: ImportSpecifierType;
|
|
353
|
+
/** The name being imported */
|
|
354
|
+
name: string;
|
|
355
|
+
/** Whether this is a type-only import */
|
|
356
|
+
isType: boolean;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Represents the collection of specifiers in an import statement.
|
|
360
|
+
*/
|
|
361
|
+
interface ImportSpecifiers {
|
|
362
|
+
/** The raw code containing all specifiers */
|
|
363
|
+
code: string;
|
|
364
|
+
/** Array of individual specifiers */
|
|
365
|
+
children: ImportSpecifier[];
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Represents the module path portion of an import statement.
|
|
369
|
+
*/
|
|
370
|
+
interface ImportModulePath {
|
|
371
|
+
/** The raw code containing the module path */
|
|
372
|
+
code: string;
|
|
373
|
+
/** The type of path (relative, absolute, builtin, package) */
|
|
374
|
+
type: ImportPathType;
|
|
375
|
+
/** The quote character used (' or " or `) */
|
|
376
|
+
quote: string;
|
|
377
|
+
/** The actual path string */
|
|
378
|
+
path: string;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Interface representing a parsed import statement with all its components.
|
|
382
|
+
* This interface enforces consistent structure for analyzing and manipulating
|
|
383
|
+
* import statements in TypeScript source files.
|
|
384
|
+
*/
|
|
385
|
+
interface ImportStatement {
|
|
386
|
+
/** The original import statement code */
|
|
387
|
+
readonly code: string;
|
|
388
|
+
/** The import statement as a formatted single line */
|
|
389
|
+
readonly oneliner: string;
|
|
390
|
+
/** The type of import statement */
|
|
391
|
+
readonly type: ImportStatementType;
|
|
392
|
+
/** The keywords used in the import statement */
|
|
393
|
+
readonly keywords: ImportKeywords;
|
|
394
|
+
/** The import specifiers */
|
|
395
|
+
readonly specifiers: ImportSpecifiers;
|
|
396
|
+
/** The module path information */
|
|
397
|
+
readonly modulePath: ImportModulePath;
|
|
398
|
+
/** The semicolon at the end, if present */
|
|
399
|
+
readonly semi: string;
|
|
400
|
+
/**
|
|
401
|
+
* Split the import statement into as many individual import statements as possible.
|
|
402
|
+
* @param options - Configuration options for splitting
|
|
403
|
+
* @param options.unaliasNamedImports - Whether to remove aliases from named imports
|
|
404
|
+
* @returns Array of individual import statements
|
|
405
|
+
*/
|
|
406
|
+
splitBySpecifier(options?: {
|
|
407
|
+
unaliasNamedImports?: boolean;
|
|
408
|
+
}): ImportStatement[];
|
|
409
|
+
/**
|
|
410
|
+
* Returns a sorted array of unique names that this import statement declares in the global namespace.
|
|
411
|
+
* @param options - Configuration options for name extraction
|
|
412
|
+
* @param options.unaliasNamedImports - Whether to remove aliases from named imports
|
|
413
|
+
* @returns Array of declared names
|
|
414
|
+
*/
|
|
415
|
+
getNames(options?: {
|
|
416
|
+
unaliasNamedImports?: boolean;
|
|
417
|
+
}): string[];
|
|
2598
418
|
}
|
|
2599
419
|
|
|
2600
420
|
/**
|
|
2601
|
-
*
|
|
421
|
+
* An import statement together with the file it was found in.
|
|
2602
422
|
*/
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
get monoRepo(): MonoRepo;
|
|
2609
|
-
get packageJsonPath(): string;
|
|
2610
|
-
get tsconfigBaseJsonPath(): string;
|
|
2611
|
-
get tsconfigBase(): SetFieldType<TsConfigJson, "compilerOptions", TsConfigJson["compilerOptions"] & {
|
|
2612
|
-
paths: CompilerOptions["paths"];
|
|
2613
|
-
}>;
|
|
2614
|
-
get tsconfigBasePathsJsonPath(): string;
|
|
2615
|
-
get tsconfigBasePaths(): Record<string, string[]>;
|
|
2616
|
-
get packageJson(): PackageJson;
|
|
2617
|
-
get name(): string;
|
|
2618
|
-
get workspacesRootPaths(): string[];
|
|
2619
|
-
get workspacePaths(): string[];
|
|
2620
|
-
get workspaces(): Workspace[];
|
|
423
|
+
interface FileImport {
|
|
424
|
+
/** The path of the file that contains the import statement, as it was given. */
|
|
425
|
+
filepath: string;
|
|
426
|
+
/** The parsed import statement. */
|
|
427
|
+
statement: ImportStatement;
|
|
2621
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Reads a TypeScript file and parses its import statements.
|
|
431
|
+
*/
|
|
432
|
+
declare function getFileImports(filepath: string): FileImport[];
|
|
2622
433
|
|
|
2623
434
|
/**
|
|
2624
|
-
*
|
|
435
|
+
* Parses the import statements of every source file in the given workspaces.
|
|
436
|
+
*
|
|
437
|
+
* @param workspaces - Defaults to all workspaces of the repo that contains the current working directory.
|
|
2625
438
|
*/
|
|
2626
|
-
declare function
|
|
439
|
+
declare function getAllImports(workspaces?: Workspace[]): FileImport[];
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* An import where a file imports its own workspace by package name instead of by relative path.
|
|
443
|
+
*/
|
|
444
|
+
interface WorkspaceSelfImport {
|
|
445
|
+
/** Absolute path of the file that contains the import. */
|
|
446
|
+
filepath: string;
|
|
447
|
+
/** The module specifier to replace: the workspace's package name. */
|
|
448
|
+
replaceValue: string;
|
|
449
|
+
/** The relative module specifier to replace it with. */
|
|
450
|
+
withValue: string;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Finds the imports in a workspace's files that import the workspace itself by its package name.
|
|
454
|
+
* Such imports should be relative instead.
|
|
455
|
+
*
|
|
456
|
+
* The suggested replacement points at the source file named after the first imported name, if there is one.
|
|
457
|
+
* Otherwise it points at the workspace's src/index file.
|
|
458
|
+
*/
|
|
459
|
+
declare function getWorkspaceSelfImports(workspace: Workspace): WorkspaceSelfImport[];
|
|
2627
460
|
|
|
2628
461
|
/**
|
|
2629
|
-
*
|
|
462
|
+
* Finds the full package name for a workspace given a partial name.
|
|
2630
463
|
*/
|
|
2631
|
-
declare function
|
|
464
|
+
declare function findWorkspacePackageName(name: string): Promise<string | undefined>;
|
|
2632
465
|
|
|
2633
466
|
/**
|
|
2634
467
|
* Gets all workspace package.json file paths.
|
|
@@ -2650,51 +483,15 @@ declare function getAllWorkspacePackageNames(): Promise<string[]>;
|
|
|
2650
483
|
*/
|
|
2651
484
|
declare function getAllWorkspacePaths(): Promise<string[]>;
|
|
2652
485
|
|
|
2653
|
-
/**
|
|
2654
|
-
* Recursively retrieves all imports for the given entry points, categorizing them into external, builtin, and internal dependencies.
|
|
2655
|
-
*
|
|
2656
|
-
* @param entryPoints - An array of entry point file paths to analyze.
|
|
2657
|
-
* @returns An object containing the file paths of all imports and categorized dependencies.
|
|
2658
|
-
*/
|
|
2659
|
-
declare function getImportsRecursively(entryPoints: string[]): Promise<Result>;
|
|
2660
|
-
type Result = {
|
|
2661
|
-
/**
|
|
2662
|
-
* All file paths of the imports found recursively, in discovery order, starting from the entry points, including circular reference stops.
|
|
2663
|
-
*/
|
|
2664
|
-
filepaths: string[];
|
|
2665
|
-
/**
|
|
2666
|
-
* All workspace imports found recursively. Includes all `local` imports plus for any other worksapce imports discovered.
|
|
2667
|
-
*/
|
|
2668
|
-
recursive: {
|
|
2669
|
-
/** External dependencies */
|
|
2670
|
-
external: string[];
|
|
2671
|
-
/** Built-in node dependencies */
|
|
2672
|
-
builtin: string[];
|
|
2673
|
-
/** Other repo workspaces */
|
|
2674
|
-
internal: string[];
|
|
2675
|
-
};
|
|
2676
|
-
/**
|
|
2677
|
-
* Only workspace imports found in the same workspace as the entry points.
|
|
2678
|
-
*/
|
|
2679
|
-
local: {
|
|
2680
|
-
/** External dependencies */
|
|
2681
|
-
external: string[];
|
|
2682
|
-
/** Built-in node dependencies */
|
|
2683
|
-
builtin: string[];
|
|
2684
|
-
/** Other repo workspaces */
|
|
2685
|
-
internal: string[];
|
|
2686
|
-
};
|
|
2687
|
-
};
|
|
2688
|
-
|
|
2689
486
|
/**
|
|
2690
487
|
* Reads the repository's root package.json file.
|
|
2691
488
|
*/
|
|
2692
|
-
declare function
|
|
489
|
+
declare function getRootPackageJson(): Promise<any>;
|
|
2693
490
|
|
|
2694
491
|
/**
|
|
2695
492
|
* Gets the absolute path to the repository's package.json file.
|
|
2696
493
|
*/
|
|
2697
|
-
declare function
|
|
494
|
+
declare function getRootPackageJsonPath(): string;
|
|
2698
495
|
|
|
2699
496
|
/**
|
|
2700
497
|
* Constants for semantic filename prefixes used to categorize files by their purpose.
|
|
@@ -2724,7 +521,17 @@ declare const SemanticExtnamePrefixDescriptions: Record<SemanticExtnamePrefix, s
|
|
|
2724
521
|
/**
|
|
2725
522
|
* Get the root directory path of the monorepo by finding the package.json with workspaces configuration.
|
|
2726
523
|
*/
|
|
2727
|
-
declare const getRepoRootDirpath: () => string
|
|
524
|
+
declare const getRepoRootDirpath: ((fspath?: string) => string) & {
|
|
525
|
+
cache: es_toolkit.MemoizeCache<any, string>;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Reads the 'compilerOptions.paths' of the tsconfig.paths.json file in the repo root.
|
|
530
|
+
* Returns an empty object if the file does not exist.
|
|
531
|
+
*
|
|
532
|
+
* @param root - The repo root. Defaults to the root of the repo that contains the current working directory.
|
|
533
|
+
*/
|
|
534
|
+
declare function getTsconfigPaths(root?: string): Record<string, string[]>;
|
|
2728
535
|
|
|
2729
536
|
/**
|
|
2730
537
|
* Get all workspace directory paths by reading the workspace patterns from the root package.json.
|
|
@@ -2736,6 +543,17 @@ declare function getWorkspaceDirpaths(): string[];
|
|
|
2736
543
|
*/
|
|
2737
544
|
declare function hasExtnamePrefix(tsFilepath: string, prefixes?: Arrayable<SemanticExtnamePrefix>): boolean;
|
|
2738
545
|
|
|
546
|
+
/**
|
|
547
|
+
* Whether the file is a source file: located in a 'src' directory and without a semantic extname prefix.
|
|
548
|
+
* So not a test file, example file, declaration file etc.
|
|
549
|
+
*/
|
|
550
|
+
declare function isSourceFile(filepath: string): boolean;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Whether the file is a test file, e.g. 'foo.test.ts'.
|
|
554
|
+
*/
|
|
555
|
+
declare function isTestFile(filepath: string): boolean;
|
|
556
|
+
|
|
2739
557
|
/**
|
|
2740
558
|
* Returns the resolved import path (relative from repo root)
|
|
2741
559
|
*/
|
|
@@ -2762,4 +580,50 @@ declare function resolveModuleImportPath(filepath: string, importFrom: string):
|
|
|
2762
580
|
*/
|
|
2763
581
|
declare function semverVersionBump(version: string | string[] | number[], level: 'major' | 'minor' | 'patch'): string;
|
|
2764
582
|
|
|
2765
|
-
|
|
583
|
+
/**
|
|
584
|
+
* Finds a workspace by its package name, its directory name or its path relative to the repo root.
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```ts
|
|
588
|
+
* findWorkspace('@mono/string') // by package name
|
|
589
|
+
* findWorkspace('string') // by directory name
|
|
590
|
+
* findWorkspace('libs/string') // by path relative to the repo root
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
declare function findWorkspace(query: string, workspaces?: Workspace[]): Workspace | undefined;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Lists the absolute paths of all TypeScript files in the 'src' directory of a workspace, sorted.
|
|
597
|
+
* This includes test files and other files with a semantic extname prefix. Filter with `isSourceFile` or
|
|
598
|
+
* `isTestFile`, or use `getWorkspaceSourceFiles` or `getWorkspaceTestFiles`.
|
|
599
|
+
*/
|
|
600
|
+
declare function getWorkspaceFiles(workspace: Workspace): string[];
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Lists the absolute paths of the source files of a workspace: the TypeScript files in its 'src' directory that
|
|
604
|
+
* have no semantic extname prefix. So no test files, example files, declaration files etc.
|
|
605
|
+
*/
|
|
606
|
+
declare function getWorkspaceSourceFiles(workspace: Workspace): string[];
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Lists the absolute paths of the test files (*.test.*) in the 'src' directory of a workspace.
|
|
610
|
+
*/
|
|
611
|
+
declare function getWorkspaceTestFiles(workspace: Workspace): string[];
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Reads every workspace matched by the 'workspaces' patterns of the root package.json.
|
|
615
|
+
* The repo root itself is not included.
|
|
616
|
+
*
|
|
617
|
+
* @param root - The repo root. Defaults to the root of the repo that contains the current working directory.
|
|
618
|
+
*/
|
|
619
|
+
declare function getWorkspaces(root?: string): Workspace[];
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Reads the package.json of a workspace directory and returns the workspace as plain data.
|
|
623
|
+
*
|
|
624
|
+
* @param dirpath - The workspace directory. A relative path is resolved against the repo root.
|
|
625
|
+
* @param root - The repo root. Defaults to the root of the repo that contains the current working directory.
|
|
626
|
+
*/
|
|
627
|
+
declare function readWorkspace(dirpath: string, root?: string): Workspace;
|
|
628
|
+
|
|
629
|
+
export { type CreateDependencyGraphOptions, type DependencyGraph, type DependencyKind, type DependencySummary, type FileImport, type GraphDependency, type GraphModule, type ImportedDependencies, type ImportsRecursivelyResult, SemanticExtnamePrefix, SemanticExtnamePrefixDescriptions, type Workspace, type WorkspaceDependencyProblems, type WorkspaceSelfImport, createDependencyGraph, findWorkspace, findWorkspacePackageName, getAllImports, getAllWorkspacePackageJsonPaths, getAllWorkspacePackageJsons, getAllWorkspacePackageNames, getAllWorkspacePaths, getDependencyName, getExternalDependencyVersions, getFileImports, getImportsRecursively, getReachableModules, getRepoRootDirpath, getRootPackageJson, getRootPackageJsonPath, getTsconfigPaths, getWorkspaceDependencies, getWorkspaceDependencyProblems, getWorkspaceDirpaths, getWorkspaceFiles, getWorkspaceModules, getWorkspaceSelfImports, getWorkspaceSourceFiles, getWorkspaceTestFiles, getWorkspaces, hasExtnamePrefix, isSourceFile, isTestFile, readWorkspace, resolveModuleImportPath, semverVersionBump, summarizeDependencies };
|