@visulima/packem 2.0.0-alpha.2 → 2.0.0-alpha.21

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +263 -1
  2. package/README.md +15 -11
  3. package/dist/builder/typedoc/index.d.ts +8 -8
  4. package/dist/builder/typedoc/index.js +3 -0
  5. package/dist/cli/index.js +55 -0
  6. package/dist/config/index.d.ts +9 -10
  7. package/dist/index.d.ts +9 -8
  8. package/dist/index.js +1 -0
  9. package/dist/packem_shared/default-BYM_JvQL.js +1 -0
  10. package/dist/packem_shared/default-B_dUKZ_J.js +1 -0
  11. package/dist/packem_shared/default-DjNIGH2Y.js +1 -0
  12. package/dist/packem_shared/default-DpHYpsSt.js +1 -0
  13. package/dist/packem_shared/default-DqRcOUe1.js +1 -0
  14. package/dist/packem_shared/esbuildPlugin-CXr7ud3R-CwR2FCHj.js +3 -0
  15. package/dist/packem_shared/index-CFFENGTN.js +145 -0
  16. package/dist/packem_shared/{index-Sedl0fV9.d.mts → index-zrs6Po_w.d.ts} +2745 -58
  17. package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Cpfv95eA.js +4 -0
  18. package/dist/packem_shared/swcPlugin-Boip4lWG-CwJ-HVJc.js +1 -0
  19. package/dist/packem_shared/types-5psa8MJc.d.ts +165 -0
  20. package/dist/rollup/plugins/css/loaders/less.d.ts +1 -2
  21. package/dist/rollup/plugins/css/loaders/less.js +1 -0
  22. package/dist/rollup/plugins/css/loaders/lightningcss.d.ts +1 -2
  23. package/dist/rollup/plugins/css/loaders/lightningcss.js +1 -0
  24. package/dist/rollup/plugins/css/loaders/postcss.d.ts +1 -2
  25. package/dist/rollup/plugins/css/loaders/postcss.js +1 -0
  26. package/dist/rollup/plugins/css/loaders/sass.d.ts +1 -2
  27. package/dist/rollup/plugins/css/loaders/sass.js +1 -0
  28. package/dist/rollup/plugins/css/loaders/sourcemap.d.ts +9 -9
  29. package/dist/rollup/plugins/css/loaders/sourcemap.js +1 -0
  30. package/dist/rollup/plugins/css/loaders/stylus.d.ts +1 -2
  31. package/dist/rollup/plugins/css/loaders/stylus.js +1 -0
  32. package/dist/rollup/plugins/css/{minifiers/lightningcss.mjs → loaders/tailwindcss.d.ts} +1 -1
  33. package/dist/rollup/plugins/css/loaders/tailwindcss.js +1 -0
  34. package/dist/rollup/plugins/css/minifiers/cssnano.d.ts +1 -2
  35. package/dist/rollup/plugins/css/minifiers/cssnano.js +1 -0
  36. package/dist/rollup/plugins/css/minifiers/lightningcss.d.ts +1 -2
  37. package/dist/rollup/plugins/css/minifiers/lightningcss.js +1 -0
  38. package/dist/rollup/plugins/esbuild/index.d.ts +7 -5
  39. package/dist/rollup/plugins/esbuild/index.js +1 -0
  40. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +25 -10
  41. package/dist/rollup/plugins/oxc/{isolated-declarations-oxc-transformer.mjs → isolated-declarations-oxc-transformer.js} +1 -1
  42. package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +7 -6
  43. package/dist/rollup/plugins/oxc/{oxc-transformer.mjs → oxc-transformer.js} +1 -1
  44. package/dist/rollup/plugins/sucrase/index.d.ts +5 -4
  45. package/dist/rollup/plugins/sucrase/index.js +1 -0
  46. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +6 -5
  47. package/dist/rollup/plugins/swc/{isolated-declarations-swc-transformer.mjs → isolated-declarations-swc-transformer.js} +1 -1
  48. package/dist/rollup/plugins/swc/swc-plugin.d.ts +26 -10
  49. package/dist/rollup/plugins/swc/swc-plugin.js +1 -0
  50. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +6 -4
  51. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -0
  52. package/files.d.ts +37 -0
  53. package/package.json +67 -55
  54. package/dist/builder/typedoc/index.d.mts +0 -27
  55. package/dist/builder/typedoc/index.mjs +0 -3
  56. package/dist/cli/index.mjs +0 -55
  57. package/dist/config/index.d.mts +0 -29
  58. package/dist/index.d.mts +0 -35
  59. package/dist/index.mjs +0 -1
  60. package/dist/packem_shared/default-CBa9Nwy_.mjs +0 -1
  61. package/dist/packem_shared/default-DlLVgYRF.mjs +0 -1
  62. package/dist/packem_shared/default-DrXMWF-8.mjs +0 -1
  63. package/dist/packem_shared/default-DuCyCmG2.mjs +0 -1
  64. package/dist/packem_shared/default-lC8LWTO_.mjs +0 -1
  65. package/dist/packem_shared/esbuildPlugin-BAwyhG6L-BTISgbUT.mjs +0 -3
  66. package/dist/packem_shared/index-CG57YXz-.mjs +0 -138
  67. package/dist/packem_shared/index-Sedl0fV9.d.ts +0 -2554
  68. package/dist/packem_shared/oxcTransformPlugin-DfVQouIB-Bxgxc0jX.mjs +0 -4
  69. package/dist/packem_shared/swcPlugin-Boip4lWG-DWNziB_j.mjs +0 -1
  70. package/dist/packem_shared/types-Bgf1bUQM.d.mts +0 -2765
  71. package/dist/packem_shared/types-C-wHDExv.d.ts +0 -2765
  72. package/dist/rollup/plugins/css/loaders/less.d.mts +0 -1
  73. package/dist/rollup/plugins/css/loaders/less.mjs +0 -1
  74. package/dist/rollup/plugins/css/loaders/lightningcss.d.mts +0 -1
  75. package/dist/rollup/plugins/css/loaders/lightningcss.mjs +0 -1
  76. package/dist/rollup/plugins/css/loaders/postcss.d.mts +0 -1
  77. package/dist/rollup/plugins/css/loaders/postcss.mjs +0 -1
  78. package/dist/rollup/plugins/css/loaders/sass.d.mts +0 -1
  79. package/dist/rollup/plugins/css/loaders/sass.mjs +0 -1
  80. package/dist/rollup/plugins/css/loaders/sourcemap.d.mts +0 -8
  81. package/dist/rollup/plugins/css/loaders/sourcemap.mjs +0 -1
  82. package/dist/rollup/plugins/css/loaders/stylus.d.mts +0 -1
  83. package/dist/rollup/plugins/css/loaders/stylus.mjs +0 -1
  84. package/dist/rollup/plugins/css/minifiers/cssnano.d.mts +0 -1
  85. package/dist/rollup/plugins/css/minifiers/cssnano.mjs +0 -1
  86. package/dist/rollup/plugins/css/minifiers/lightningcss.d.mts +0 -1
  87. package/dist/rollup/plugins/esbuild/index.d.mts +0 -22
  88. package/dist/rollup/plugins/esbuild/index.mjs +0 -1
  89. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.mts +0 -23
  90. package/dist/rollup/plugins/oxc/oxc-transformer.d.mts +0 -18
  91. package/dist/rollup/plugins/sucrase/index.d.mts +0 -17
  92. package/dist/rollup/plugins/sucrase/index.mjs +0 -1
  93. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.mts +0 -18
  94. package/dist/rollup/plugins/swc/swc-plugin.d.mts +0 -24
  95. package/dist/rollup/plugins/swc/swc-plugin.mjs +0 -1
  96. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.mts +0 -22
  97. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.mjs +0 -1
  98. /package/dist/config/{index.mjs → index.js} +0 -0
  99. /package/dist/packem_shared/{browserslistToEsbuild-C0IWmbNe-C6xPL1oW.mjs → browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js} +0 -0
  100. /package/dist/packem_shared/{create-or-update-key-storage-GwAIWW7R.mjs → create-or-update-key-storage-GwAIWW7R.js} +0 -0
  101. /package/dist/packem_shared/{index-CUp9WuCG.mjs → index-CUp9WuCG.js} +0 -0
  102. /package/dist/packem_shared/{isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.mjs → isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js} +0 -0
  103. /package/dist/packem_shared/{isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.mjs → isolatedDeclarationsSwcTransformer-Ch2AgtWC-B-0lOgFf.js} +0 -0
  104. /package/dist/packem_shared/{isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.mjs → isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js} +0 -0
  105. /package/dist/packem_shared/{oxcResolvePlugin-BJpi-eSG-BsYx9cDO.mjs → oxcResolvePlugin-BJpi-eSG-BsYx9cDO.js} +0 -0
  106. /package/dist/packem_shared/{resolveTypescriptMjsCtsPlugin-DcZrZTmM-BEkYWTsH.mjs → resolveTypescriptMjsCtsPlugin-DcZrZTmM-BEkYWTsH.js} +0 -0
@@ -1,20 +1,2693 @@
1
- import { FilterPattern } from '@rollup/pluginutils';
2
- import { OutputOptions, Plugin as Plugin$1, RollupOptions } from 'rollup';
3
1
  import { RollupAliasOptions } from '@rollup/plugin-alias';
4
2
  import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
5
3
  import { RollupJsonOptions } from '@rollup/plugin-json';
6
4
  import { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
7
5
  import { RollupReplaceOptions } from '@rollup/plugin-replace';
8
6
  import { RollupWasmOptions } from '@rollup/plugin-wasm';
7
+ import { FilterPattern } from '@rollup/pluginutils';
8
+ import { RollupBuild, RollupOptions, RollupWatcher, OutputOptions, Plugin as Plugin$1 } from 'rollup';
9
9
  import { Options as Options$2 } from 'rollup-plugin-dts';
10
10
  import { NodePolyfillsOptions } from 'rollup-plugin-polyfill-node';
11
11
  import { PureAnnotationsOptions } from 'rollup-plugin-pure';
12
12
  import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
13
- import { TransformOptions, Loader, BuildOptions } from 'esbuild';
13
+ import { TransformOptions as TransformOptions$1, Loader, BuildOptions } from 'esbuild';
14
+ import { PackageJson } from '@visulima/package';
15
+ import { AnsiColors as AnsiColors$1 } from '@visulima/colorize';
14
16
  import { NapiResolveOptions } from 'oxc-resolver';
15
- import { TransformOptions as TransformOptions$1, JsxOptions } from 'oxc-transform';
17
+ import { TransformOptions as TransformOptions$2, JsxOptions } from 'oxc-transform';
16
18
  import { Options as Options$3 } from 'sucrase';
17
19
 
20
+ /**
21
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
22
+
23
+ @category Type
24
+ */
25
+ type Primitive$1 =
26
+ | null
27
+ | undefined
28
+ | string
29
+ | number
30
+ | boolean
31
+ | symbol
32
+ | bigint;
33
+
34
+ declare global {
35
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
36
+ interface SymbolConstructor {
37
+ readonly observable: symbol;
38
+ }
39
+ }
40
+
41
+ /**
42
+ Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
43
+
44
+ Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
45
+
46
+ This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
47
+
48
+ @example
49
+ ```
50
+ import type {LiteralUnion} from 'type-fest';
51
+
52
+ // Before
53
+
54
+ type Pet = 'dog' | 'cat' | string;
55
+
56
+ const pet: Pet = '';
57
+ // Start typing in your TypeScript-enabled IDE.
58
+ // You **will not** get auto-completion for `dog` and `cat` literals.
59
+
60
+ // After
61
+
62
+ type Pet2 = LiteralUnion<'dog' | 'cat', string>;
63
+
64
+ const pet: Pet2 = '';
65
+ // You **will** get auto-completion for `dog` and `cat` literals.
66
+ ```
67
+
68
+ @category Type
69
+ */
70
+ type LiteralUnion$1<
71
+ LiteralType,
72
+ BaseType extends Primitive$1,
73
+ > = LiteralType | (BaseType & Record<never, never>);
74
+
75
+ declare class InteractiveStreamHook$1 {
76
+ #private;
77
+ static readonly DRAIN = true;
78
+ constructor(stream: NodeJS.WriteStream);
79
+ active(): void;
80
+ erase(count: number): void;
81
+ inactive(separateHistory?: boolean): void;
82
+ renew(): void;
83
+ write(message: string): void;
84
+ }
85
+
86
+ type StreamType$1 = "stderr" | "stdout";
87
+ declare class InteractiveManager$1 {
88
+ #private;
89
+ constructor(stdout: InteractiveStreamHook$1, stderr: InteractiveStreamHook$1);
90
+ get lastLength(): number;
91
+ get outside(): number;
92
+ get isHooked(): boolean;
93
+ get isSuspended(): boolean;
94
+ erase(stream: StreamType$1, count?: number): void;
95
+ hook(): boolean;
96
+ resume(stream: StreamType$1, eraseRowCount?: number): void;
97
+ suspend(stream: StreamType$1, erase?: boolean): void;
98
+ unhook(separateHistory?: boolean): boolean;
99
+ update(stream: StreamType$1, rows: string[], from?: number): void;
100
+ private _clear;
101
+ }
102
+
103
+ declare global {
104
+ namespace VisulimaPail {
105
+ interface CustomMeta<L> {
106
+ }
107
+ }
108
+ }
109
+ interface Meta$1<L> extends VisulimaPail.CustomMeta<L> {
110
+ badge: string | undefined;
111
+ context: any[] | undefined;
112
+ date: Date | string;
113
+ error: Error | undefined;
114
+ groups: string[];
115
+ label: string | undefined;
116
+ message: Primitive$1 | ReadonlyArray<unknown> | Record<PropertyKey, unknown>;
117
+ prefix: string | undefined;
118
+ repeated?: number | undefined;
119
+ scope: string[] | undefined;
120
+ suffix: string | undefined;
121
+ traceError: Error | undefined;
122
+ type: {
123
+ level: ExtendedRfc5424LogLevels$1 | L;
124
+ name: string;
125
+ };
126
+ }
127
+ type ExtendedRfc5424LogLevels$1 = "alert" | "critical" | "debug" | "emergency" | "error" | "informational" | "notice" | "trace" | "warning";
128
+ type DefaultLogTypes$1 = "alert" | "await" | "complete" | "critical" | "debug" | "emergency" | "error" | "info" | "log" | "notice" | "pending" | "start" | "stop" | "success" | "trace" | "wait" | "warn" | "watch";
129
+ interface LoggerFunction$1 {
130
+ (message: Message$1): void;
131
+ (...message: any[]): void;
132
+ }
133
+ interface LoggerConfiguration$1<L extends string> {
134
+ badge?: string;
135
+ color?: AnsiColors$1 | undefined;
136
+ label: string;
137
+ logLevel: LiteralUnion$1<ExtendedRfc5424LogLevels$1, L>;
138
+ }
139
+ type LoggerTypesConfig$1<T extends string, L extends string> = Record<T, Partial<LoggerConfiguration$1<L>>>;
140
+ type ReadonlyMeta$1<L extends string> = Readonly<Meta$1<L>>;
141
+ interface Reporter$1<L extends string> {
142
+ log: (meta: ReadonlyMeta$1<L>) => void;
143
+ }
144
+ interface Processor$1<L extends string> {
145
+ process: (meta: Meta$1<L>) => Meta$1<L>;
146
+ }
147
+ interface ConstructorOptions$1<T extends string, L extends string> {
148
+ disabled?: boolean;
149
+ logLevel?: LiteralUnion$1<ExtendedRfc5424LogLevels$1, L>;
150
+ logLevels?: Partial<Record<ExtendedRfc5424LogLevels$1, number>> & Record<L, number>;
151
+ messages?: {
152
+ timerEnd?: string;
153
+ timerStart?: string;
154
+ };
155
+ processors?: Processor$1<L>[];
156
+ rawReporter?: Reporter$1<L>;
157
+ reporters?: Reporter$1<L>[];
158
+ scope?: string[] | string;
159
+ throttle?: number;
160
+ throttleMin?: number;
161
+ types?: LoggerTypesConfig$1<T, L> & Partial<LoggerTypesConfig$1<DefaultLogTypes$1, L>>;
162
+ }
163
+ interface ServerConstructorOptions$1<T extends string, L extends string> extends ConstructorOptions$1<T, L> {
164
+ interactive?: boolean;
165
+ stderr: NodeJS.WriteStream;
166
+ stdout: NodeJS.WriteStream;
167
+ }
168
+ type Message$1 = {
169
+ context?: any[] | undefined;
170
+ message: any;
171
+ prefix?: string;
172
+ suffix?: string;
173
+ };
174
+
175
+ type Replacer$1 = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null | object)
176
+
177
+ interface StringifyOptions$1 {
178
+ bigint?: boolean,
179
+ circularValue?: string | null | TypeErrorConstructor | ErrorConstructor,
180
+ deterministic?: boolean | ((a: string, b: string) => number),
181
+ maximumBreadth?: number,
182
+ maximumDepth?: number,
183
+ strict?: boolean,
184
+ }
185
+
186
+ declare function stringify$1(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer$1, space?: string | number): undefined
187
+ declare function stringify$1(value: string | number | unknown[] | null | boolean | object, replacer?: Replacer$1, space?: string | number): string
188
+ declare function stringify$1(value: unknown, replacer?: ((key: string, value: unknown) => unknown) | (number | string)[] | null | undefined, space?: string | number): string | undefined
189
+
190
+ declare namespace stringify$1 {
191
+ export function configure(options: StringifyOptions$1): typeof stringify$1
192
+ }
193
+
194
+ declare class PailBrowserImpl$1<T extends string = string, L extends string = string> {
195
+ protected timersMap: Map<string, number>;
196
+ protected countMap: Map<string, number>;
197
+ protected seqTimers: Set<string>;
198
+ protected readonly lastLog: {
199
+ count?: number;
200
+ object?: Meta$1<L>;
201
+ serialized?: string;
202
+ time?: Date;
203
+ timeout?: ReturnType<typeof setTimeout>;
204
+ };
205
+ protected readonly logLevels: Record<string, number>;
206
+ protected disabled: boolean;
207
+ protected scopeName: string[];
208
+ protected readonly types: LoggerTypesConfig$1<LiteralUnion$1<DefaultLogTypes$1, T>, L>;
209
+ protected readonly longestLabel: string;
210
+ protected readonly processors: Set<Processor$1<L>>;
211
+ protected readonly generalLogLevel: LiteralUnion$1<ExtendedRfc5424LogLevels$1, L>;
212
+ protected reporters: Set<Reporter$1<L>>;
213
+ protected readonly throttle: number;
214
+ protected readonly throttleMin: number;
215
+ protected readonly stringify: typeof stringify$1;
216
+ protected groups: string[];
217
+ protected readonly startTimerMessage: string;
218
+ protected readonly endTimerMessage: string;
219
+ protected rawReporter: Reporter$1<L>;
220
+ constructor(options: ConstructorOptions$1<T, L>);
221
+ wrapConsole(): void;
222
+ restoreConsole(): void;
223
+ wrapException(): void;
224
+ disable(): void;
225
+ enable(): void;
226
+ isEnabled(): boolean;
227
+ scope<N extends string = T>(...name: string[]): PailBrowserType$1<N, L>;
228
+ unscope(): void;
229
+ time(label?: string): void;
230
+ timeLog(label?: string, ...data: unknown[]): void;
231
+ timeEnd(label?: string): void;
232
+ group(label?: string): void;
233
+ groupEnd(): void;
234
+ count(label?: string): void;
235
+ countReset(label?: string): void;
236
+ clear(): void;
237
+ raw(message: string, ...arguments_: unknown[]): void;
238
+ protected extendReporter(reporter: Reporter$1<L>): Reporter$1<L>;
239
+ protected registerReporters(reporters: Reporter$1<L>[]): void;
240
+ private _report;
241
+ private registerProcessors;
242
+ private _normalizeLogLevel;
243
+ private _buildMeta;
244
+ private _logger;
245
+ }
246
+ type PailBrowserType$1<T extends string = string, L extends string = string> = PailBrowserImpl$1<T, L> & Record<DefaultLogTypes$1, LoggerFunction$1> & Record<T, LoggerFunction$1> & (new <TC extends string = string, LC extends string = string>(options?: ConstructorOptions$1<TC, LC>) => PailBrowserType$1<TC, LC>);
247
+
248
+ declare class PailServerImpl$1<T extends string = string, L extends string = string> extends PailBrowserImpl$1<T, L> {
249
+ readonly options: ServerConstructorOptions$1<T, L>;
250
+ protected readonly stdout: NodeJS.WriteStream;
251
+ protected readonly stderr: NodeJS.WriteStream;
252
+ protected interactiveManager: InteractiveManager$1 | undefined;
253
+ protected readonly interactive: boolean;
254
+ constructor(options: ServerConstructorOptions$1<T, L>);
255
+ scope<N extends string = T>(...name: string[]): PailServerType$1<N, L>;
256
+ getInteractiveManager(): InteractiveManager$1 | undefined;
257
+ wrapStd(): void;
258
+ restoreStd(): void;
259
+ wrapAll(): void;
260
+ restoreAll(): void;
261
+ clear(): void;
262
+ protected extendReporter(reporter: Reporter$1<L>): Reporter$1<L>;
263
+ private _wrapStream;
264
+ private _restoreStream;
265
+ }
266
+ type PailServerType$1<T extends string = string, L extends string = string> = PailServerImpl$1<T, L> & Record<DefaultLogTypes$1, LoggerFunction$1> & Record<T, LoggerFunction$1> & (new <TC extends string = string, LC extends string = string>(options?: ServerConstructorOptions$1<TC, LC>) => PailServerType$1<TC, LC>);
267
+
268
+ declare global {
269
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
270
+ interface SymbolConstructor {
271
+ readonly observable: symbol;
272
+ }
273
+ }
274
+
275
+ /**
276
+ Extract all optional keys from the given type.
277
+
278
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
279
+
280
+ @example
281
+ ```
282
+ import type {OptionalKeysOf, Except} from 'type-fest';
283
+
284
+ interface User {
285
+ name: string;
286
+ surname: string;
287
+
288
+ luckyNumber?: number;
289
+ }
290
+
291
+ const REMOVE_FIELD = Symbol('remove field symbol');
292
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
293
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
294
+ };
295
+
296
+ const update1: UpdateOperation<User> = {
297
+ name: 'Alice'
298
+ };
299
+
300
+ const update2: UpdateOperation<User> = {
301
+ name: 'Bob',
302
+ luckyNumber: REMOVE_FIELD
303
+ };
304
+ ```
305
+
306
+ @category Utilities
307
+ */
308
+ type OptionalKeysOf<BaseType extends object> =
309
+ BaseType extends unknown // For distributing `BaseType`
310
+ ? (keyof {
311
+ [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
312
+ }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
313
+ : never; // Should never happen
314
+
315
+ /**
316
+ Extract all required keys from the given type.
317
+
318
+ 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...
319
+
320
+ @example
321
+ ```
322
+ import type {RequiredKeysOf} from 'type-fest';
323
+
324
+ declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
325
+
326
+ interface User {
327
+ name: string;
328
+ surname: string;
329
+
330
+ luckyNumber?: number;
331
+ }
332
+
333
+ const validator1 = createValidation<User>('name', value => value.length < 25);
334
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
335
+ ```
336
+
337
+ @category Utilities
338
+ */
339
+ type RequiredKeysOf<BaseType extends object> =
340
+ BaseType extends unknown // For distributing `BaseType`
341
+ ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>>
342
+ : never; // Should never happen
343
+
344
+ /**
345
+ Returns a boolean for whether the given type is `never`.
346
+
347
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
348
+ @link https://stackoverflow.com/a/53984913/10292952
349
+ @link https://www.zhenghao.io/posts/ts-never
350
+
351
+ Useful in type utilities, such as checking if something does not occur.
352
+
353
+ @example
354
+ ```
355
+ import type {IsNever, And} from 'type-fest';
356
+
357
+ // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
358
+ type AreStringsEqual<A extends string, B extends string> =
359
+ And<
360
+ IsNever<Exclude<A, B>> extends true ? true : false,
361
+ IsNever<Exclude<B, A>> extends true ? true : false
362
+ >;
363
+
364
+ type EndIfEqual<I extends string, O extends string> =
365
+ AreStringsEqual<I, O> extends true
366
+ ? never
367
+ : void;
368
+
369
+ function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
370
+ if (input === output) {
371
+ process.exit(0);
372
+ }
373
+ }
374
+
375
+ endIfEqual('abc', 'abc');
376
+ //=> never
377
+
378
+ endIfEqual('abc', '123');
379
+ //=> void
380
+ ```
381
+
382
+ @category Type Guard
383
+ @category Utilities
384
+ */
385
+ type IsNever<T> = [T] extends [never] ? true : false;
386
+
387
+ /**
388
+ An if-else-like type that resolves depending on whether the given type is `never`.
389
+
390
+ @see {@link IsNever}
391
+
392
+ @example
393
+ ```
394
+ import type {IfNever} from 'type-fest';
395
+
396
+ type ShouldBeTrue = IfNever<never>;
397
+ //=> true
398
+
399
+ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
400
+ //=> 'bar'
401
+ ```
402
+
403
+ @category Type Guard
404
+ @category Utilities
405
+ */
406
+ type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
407
+ IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
408
+ );
409
+
410
+ // Can eventually be replaced with the built-in once this library supports
411
+ // TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
412
+ type NoInfer<T> = T extends infer U ? U : never;
413
+
414
+ /**
415
+ Returns a boolean for whether the given type is `any`.
416
+
417
+ @link https://stackoverflow.com/a/49928360/1490091
418
+
419
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
420
+
421
+ @example
422
+ ```
423
+ import type {IsAny} from 'type-fest';
424
+
425
+ const typedObject = {a: 1, b: 2} as const;
426
+ const anyObject: any = {a: 1, b: 2};
427
+
428
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
429
+ return obj[key];
430
+ }
431
+
432
+ const typedA = get(typedObject, 'a');
433
+ //=> 1
434
+
435
+ const anyA = get(anyObject, 'a');
436
+ //=> any
437
+ ```
438
+
439
+ @category Type Guard
440
+ @category Utilities
441
+ */
442
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
443
+
444
+ /**
445
+ Returns a boolean for whether the two given types are equal.
446
+
447
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
448
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
449
+
450
+ Use-cases:
451
+ - If you want to make a conditional branch based on the result of a comparison of two types.
452
+
453
+ @example
454
+ ```
455
+ import type {IsEqual} from 'type-fest';
456
+
457
+ // This type returns a boolean for whether the given array includes the given item.
458
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
459
+ type Includes<Value extends readonly any[], Item> =
460
+ Value extends readonly [Value[0], ...infer rest]
461
+ ? IsEqual<Value[0], Item> extends true
462
+ ? true
463
+ : Includes<rest, Item>
464
+ : false;
465
+ ```
466
+
467
+ @category Type Guard
468
+ @category Utilities
469
+ */
470
+ type IsEqual<A, B> =
471
+ (<G>() => G extends A & G | G ? 1 : 2) extends
472
+ (<G>() => G extends B & G | G ? 1 : 2)
473
+ ? true
474
+ : false;
475
+
476
+ /**
477
+ 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.
478
+
479
+ @example
480
+ ```
481
+ import type {Simplify} from 'type-fest';
482
+
483
+ type PositionProps = {
484
+ top: number;
485
+ left: number;
486
+ };
487
+
488
+ type SizeProps = {
489
+ width: number;
490
+ height: number;
491
+ };
492
+
493
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
494
+ type Props = Simplify<PositionProps & SizeProps>;
495
+ ```
496
+
497
+ 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.
498
+
499
+ 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`.
500
+
501
+ @example
502
+ ```
503
+ import type {Simplify} from 'type-fest';
504
+
505
+ interface SomeInterface {
506
+ foo: number;
507
+ bar?: string;
508
+ baz: number | undefined;
509
+ }
510
+
511
+ type SomeType = {
512
+ foo: number;
513
+ bar?: string;
514
+ baz: number | undefined;
515
+ };
516
+
517
+ const literal = {foo: 123, bar: 'hello', baz: 456};
518
+ const someType: SomeType = literal;
519
+ const someInterface: SomeInterface = literal;
520
+
521
+ function fn(object: Record<string, unknown>): void {}
522
+
523
+ fn(literal); // Good: literal object type is sealed
524
+ fn(someType); // Good: type is sealed
525
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
526
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
527
+ ```
528
+
529
+ @link https://github.com/microsoft/TypeScript/issues/15300
530
+ @see SimplifyDeep
531
+ @category Object
532
+ */
533
+ type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
534
+
535
+ /**
536
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
537
+
538
+ This is the counterpart of `PickIndexSignature`.
539
+
540
+ Use-cases:
541
+ - Remove overly permissive signatures from third-party types.
542
+
543
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
544
+
545
+ 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>`.
546
+
547
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
548
+
549
+ ```
550
+ const indexed: Record<string, unknown> = {}; // Allowed
551
+
552
+ const keyed: Record<'foo', unknown> = {}; // Error
553
+ // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
554
+ ```
555
+
556
+ 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:
557
+
558
+ ```
559
+ type Indexed = {} extends Record<string, unknown>
560
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
561
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
562
+ // => '✅ `{}` is assignable to `Record<string, unknown>`'
563
+
564
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
565
+ ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
566
+ : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
567
+ // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
568
+ ```
569
+
570
+ 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`...
571
+
572
+ ```
573
+ import type {OmitIndexSignature} from 'type-fest';
574
+
575
+ type OmitIndexSignature<ObjectType> = {
576
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
577
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
578
+ };
579
+ ```
580
+
581
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
582
+
583
+ ```
584
+ import type {OmitIndexSignature} from 'type-fest';
585
+
586
+ type OmitIndexSignature<ObjectType> = {
587
+ [KeyType in keyof ObjectType
588
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
589
+ as {} extends Record<KeyType, unknown>
590
+ ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
591
+ : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
592
+ ]: ObjectType[KeyType];
593
+ };
594
+ ```
595
+
596
+ 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.
597
+
598
+ @example
599
+ ```
600
+ import type {OmitIndexSignature} from 'type-fest';
601
+
602
+ interface Example {
603
+ // These index signatures will be removed.
604
+ [x: string]: any
605
+ [x: number]: any
606
+ [x: symbol]: any
607
+ [x: `head-${string}`]: string
608
+ [x: `${string}-tail`]: string
609
+ [x: `head-${string}-tail`]: string
610
+ [x: `${bigint}`]: string
611
+ [x: `embedded-${number}`]: string
612
+
613
+ // These explicitly defined keys will remain.
614
+ foo: 'bar';
615
+ qux?: 'baz';
616
+ }
617
+
618
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
619
+ // => { foo: 'bar'; qux?: 'baz' | undefined; }
620
+ ```
621
+
622
+ @see PickIndexSignature
623
+ @category Object
624
+ */
625
+ type OmitIndexSignature<ObjectType> = {
626
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
627
+ ? never
628
+ : KeyType]: ObjectType[KeyType];
629
+ };
630
+
631
+ /**
632
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
633
+
634
+ This is the counterpart of `OmitIndexSignature`.
635
+
636
+ @example
637
+ ```
638
+ import type {PickIndexSignature} from 'type-fest';
639
+
640
+ declare const symbolKey: unique symbol;
641
+
642
+ type Example = {
643
+ // These index signatures will remain.
644
+ [x: string]: unknown;
645
+ [x: number]: unknown;
646
+ [x: symbol]: unknown;
647
+ [x: `head-${string}`]: string;
648
+ [x: `${string}-tail`]: string;
649
+ [x: `head-${string}-tail`]: string;
650
+ [x: `${bigint}`]: string;
651
+ [x: `embedded-${number}`]: string;
652
+
653
+ // These explicitly defined keys will be removed.
654
+ ['kebab-case-key']: string;
655
+ [symbolKey]: string;
656
+ foo: 'bar';
657
+ qux?: 'baz';
658
+ };
659
+
660
+ type ExampleIndexSignature = PickIndexSignature<Example>;
661
+ // {
662
+ // [x: string]: unknown;
663
+ // [x: number]: unknown;
664
+ // [x: symbol]: unknown;
665
+ // [x: `head-${string}`]: string;
666
+ // [x: `${string}-tail`]: string;
667
+ // [x: `head-${string}-tail`]: string;
668
+ // [x: `${bigint}`]: string;
669
+ // [x: `embedded-${number}`]: string;
670
+ // }
671
+ ```
672
+
673
+ @see OmitIndexSignature
674
+ @category Object
675
+ */
676
+ type PickIndexSignature<ObjectType> = {
677
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
678
+ ? KeyType
679
+ : never]: ObjectType[KeyType];
680
+ };
681
+
682
+ // Merges two objects without worrying about index signatures.
683
+ type SimpleMerge<Destination, Source> = {
684
+ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
685
+ } & Source;
686
+
687
+ /**
688
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
689
+
690
+ @example
691
+ ```
692
+ import type {Merge} from 'type-fest';
693
+
694
+ interface Foo {
695
+ [x: string]: unknown;
696
+ [x: number]: unknown;
697
+ foo: string;
698
+ bar: symbol;
699
+ }
700
+
701
+ type Bar = {
702
+ [x: number]: number;
703
+ [x: symbol]: unknown;
704
+ bar: Date;
705
+ baz: boolean;
706
+ };
707
+
708
+ export type FooBar = Merge<Foo, Bar>;
709
+ // => {
710
+ // [x: string]: unknown;
711
+ // [x: number]: number;
712
+ // [x: symbol]: unknown;
713
+ // foo: string;
714
+ // bar: Date;
715
+ // baz: boolean;
716
+ // }
717
+ ```
718
+
719
+ @category Object
720
+ */
721
+ type Merge<Destination, Source> =
722
+ Simplify<
723
+ SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
724
+ & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
725
+ >;
726
+
727
+ /**
728
+ An if-else-like type that resolves depending on whether the given type is `any`.
729
+
730
+ @see {@link IsAny}
731
+
732
+ @example
733
+ ```
734
+ import type {IfAny} from 'type-fest';
735
+
736
+ type ShouldBeTrue = IfAny<any>;
737
+ //=> true
738
+
739
+ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
740
+ //=> 'bar'
741
+ ```
742
+
743
+ @category Type Guard
744
+ @category Utilities
745
+ */
746
+ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
747
+ IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
748
+ );
749
+
750
+ /**
751
+ Merges user specified options with default options.
752
+
753
+ @example
754
+ ```
755
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
756
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
757
+ type SpecifiedOptions = {leavesOnly: true};
758
+
759
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
760
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
761
+ ```
762
+
763
+ @example
764
+ ```
765
+ // Complains if default values are not provided for optional options
766
+
767
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
768
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
769
+ type SpecifiedOptions = {};
770
+
771
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
772
+ // ~~~~~~~~~~~~~~~~~~~
773
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
774
+ ```
775
+
776
+ @example
777
+ ```
778
+ // Complains if an option's default type does not conform to the expected type
779
+
780
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
781
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
782
+ type SpecifiedOptions = {};
783
+
784
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
785
+ // ~~~~~~~~~~~~~~~~~~~
786
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
787
+ ```
788
+
789
+ @example
790
+ ```
791
+ // Complains if an option's specified type does not conform to the expected type
792
+
793
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
794
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
795
+ type SpecifiedOptions = {leavesOnly: 'yes'};
796
+
797
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
798
+ // ~~~~~~~~~~~~~~~~
799
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
800
+ ```
801
+ */
802
+ type ApplyDefaultOptions<
803
+ Options extends object,
804
+ Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
805
+ SpecifiedOptions extends Options,
806
+ > =
807
+ IfAny<SpecifiedOptions, Defaults,
808
+ IfNever<SpecifiedOptions, Defaults,
809
+ Simplify<Merge<Defaults, {
810
+ [Key in keyof SpecifiedOptions
811
+ as Key extends OptionalKeysOf<Options>
812
+ ? Extract<SpecifiedOptions[Key], undefined> extends never
813
+ ? Key
814
+ : never
815
+ : Key
816
+ ]: SpecifiedOptions[Key]
817
+ }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
818
+ >>;
819
+
820
+ /**
821
+ Filter out keys from an object.
822
+
823
+ Returns `never` if `Exclude` is strictly equal to `Key`.
824
+ Returns `never` if `Key` extends `Exclude`.
825
+ Returns `Key` otherwise.
826
+
827
+ @example
828
+ ```
829
+ type Filtered = Filter<'foo', 'foo'>;
830
+ //=> never
831
+ ```
832
+
833
+ @example
834
+ ```
835
+ type Filtered = Filter<'bar', string>;
836
+ //=> never
837
+ ```
838
+
839
+ @example
840
+ ```
841
+ type Filtered = Filter<'bar', 'foo'>;
842
+ //=> 'bar'
843
+ ```
844
+
845
+ @see {Except}
846
+ */
847
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
848
+
849
+ type ExceptOptions = {
850
+ /**
851
+ Disallow assigning non-specified properties.
852
+
853
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
854
+
855
+ @default false
856
+ */
857
+ requireExactProps?: boolean;
858
+ };
859
+
860
+ type DefaultExceptOptions = {
861
+ requireExactProps: false;
862
+ };
863
+
864
+ /**
865
+ Create a type from an object type without certain keys.
866
+
867
+ We recommend setting the `requireExactProps` option to `true`.
868
+
869
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
870
+
871
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
872
+
873
+ @example
874
+ ```
875
+ import type {Except} from 'type-fest';
876
+
877
+ type Foo = {
878
+ a: number;
879
+ b: string;
880
+ };
881
+
882
+ type FooWithoutA = Except<Foo, 'a'>;
883
+ //=> {b: string}
884
+
885
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
886
+ //=> errors: 'a' does not exist in type '{ b: string; }'
887
+
888
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
889
+ //=> {a: number} & Partial<Record<"b", never>>
890
+
891
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
892
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
893
+
894
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
895
+
896
+ // Consider the following example:
897
+
898
+ type UserData = {
899
+ [metadata: string]: string;
900
+ email: string;
901
+ name: string;
902
+ role: 'admin' | 'user';
903
+ };
904
+
905
+ // `Omit` clearly doesn't behave as expected in this case:
906
+ type PostPayload = Omit<UserData, 'email'>;
907
+ //=> type PostPayload = { [x: string]: string; [x: number]: string; }
908
+
909
+ // In situations like this, `Except` works better.
910
+ // It simply removes the `email` key while preserving all the other keys.
911
+ type PostPayload = Except<UserData, 'email'>;
912
+ //=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
913
+ ```
914
+
915
+ @category Object
916
+ */
917
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> =
918
+ _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
919
+
920
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = {
921
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
922
+ } & (Options['requireExactProps'] extends true
923
+ ? Partial<Record<KeysType, never>>
924
+ : {});
925
+
926
+ declare namespace TsConfigJson {
927
+ namespace CompilerOptions {
928
+ export type JSX =
929
+ | 'preserve'
930
+ | 'react'
931
+ | 'react-jsx'
932
+ | 'react-jsxdev'
933
+ | 'react-native';
934
+
935
+ export type Module =
936
+ | 'CommonJS'
937
+ | 'AMD'
938
+ | 'System'
939
+ | 'UMD'
940
+ | 'ES6'
941
+ | 'ES2015'
942
+ | 'ES2020'
943
+ | 'ES2022'
944
+ | 'ESNext'
945
+ | 'Node16'
946
+ | 'Node18'
947
+ | 'NodeNext'
948
+ | 'Preserve'
949
+ | 'None'
950
+ // Lowercase alternatives
951
+ | 'commonjs'
952
+ | 'amd'
953
+ | 'system'
954
+ | 'umd'
955
+ | 'es6'
956
+ | 'es2015'
957
+ | 'es2020'
958
+ | 'es2022'
959
+ | 'esnext'
960
+ | 'node16'
961
+ | 'node18'
962
+ | 'nodenext'
963
+ | 'preserve'
964
+ | 'none';
965
+
966
+ export type NewLine =
967
+ | 'CRLF'
968
+ | 'LF'
969
+ // Lowercase alternatives
970
+ | 'crlf'
971
+ | 'lf';
972
+
973
+ export type Target =
974
+ | 'ES3'
975
+ | 'ES5'
976
+ | 'ES6'
977
+ | 'ES2015'
978
+ | 'ES2016'
979
+ | 'ES2017'
980
+ | 'ES2018'
981
+ | 'ES2019'
982
+ | 'ES2020'
983
+ | 'ES2021'
984
+ | 'ES2022'
985
+ | 'ES2023'
986
+ | 'ES2024'
987
+ | 'ESNext'
988
+ // Lowercase alternatives
989
+ | 'es3'
990
+ | 'es5'
991
+ | 'es6'
992
+ | 'es2015'
993
+ | 'es2016'
994
+ | 'es2017'
995
+ | 'es2018'
996
+ | 'es2019'
997
+ | 'es2020'
998
+ | 'es2021'
999
+ | 'es2022'
1000
+ | 'es2023'
1001
+ | 'es2024'
1002
+ | 'esnext';
1003
+
1004
+ // eslint-disable-next-line unicorn/prevent-abbreviations
1005
+ export type Lib =
1006
+ | 'ES5'
1007
+ | 'ES6'
1008
+ | 'ES7'
1009
+ | 'ES2015'
1010
+ | 'ES2015.Collection'
1011
+ | 'ES2015.Core'
1012
+ | 'ES2015.Generator'
1013
+ | 'ES2015.Iterable'
1014
+ | 'ES2015.Promise'
1015
+ | 'ES2015.Proxy'
1016
+ | 'ES2015.Reflect'
1017
+ | 'ES2015.Symbol.WellKnown'
1018
+ | 'ES2015.Symbol'
1019
+ | 'ES2016'
1020
+ | 'ES2016.Array.Include'
1021
+ | 'ES2017'
1022
+ | 'ES2017.ArrayBuffer'
1023
+ | 'ES2017.Date'
1024
+ | 'ES2017.Intl'
1025
+ | 'ES2017.Object'
1026
+ | 'ES2017.SharedMemory'
1027
+ | 'ES2017.String'
1028
+ | 'ES2017.TypedArrays'
1029
+ | 'ES2018'
1030
+ | 'ES2018.AsyncGenerator'
1031
+ | 'ES2018.AsyncIterable'
1032
+ | 'ES2018.Intl'
1033
+ | 'ES2018.Promise'
1034
+ | 'ES2018.Regexp'
1035
+ | 'ES2019'
1036
+ | 'ES2019.Array'
1037
+ | 'ES2019.Object'
1038
+ | 'ES2019.String'
1039
+ | 'ES2019.Symbol'
1040
+ | 'ES2020'
1041
+ | 'ES2020.BigInt'
1042
+ | 'ES2020.Promise'
1043
+ | 'ES2020.String'
1044
+ | 'ES2020.Symbol.WellKnown'
1045
+ | 'ES2020.SharedMemory'
1046
+ | 'ES2020.Intl'
1047
+ | 'ES2021'
1048
+ | 'ES2021.Intl'
1049
+ | 'ES2021.Promise'
1050
+ | 'ES2021.String'
1051
+ | 'ES2021.WeakRef'
1052
+ | 'ES2022'
1053
+ | 'ES2022.Array'
1054
+ | 'ES2022.Error'
1055
+ | 'ES2022.Intl'
1056
+ | 'ES2022.Object'
1057
+ | 'ES2022.RegExp'
1058
+ | 'ES2022.String'
1059
+ | 'ES2023'
1060
+ | 'ES2023.Array'
1061
+ | 'ES2023.Collection'
1062
+ | 'ES2023.Intl'
1063
+ | 'ES2024'
1064
+ | 'ES2024.ArrayBuffer'
1065
+ | 'ES2024.Collection'
1066
+ | 'ES2024.Object'
1067
+ | 'ES2024.Promise'
1068
+ | 'ES2024.Regexp'
1069
+ | 'ES2024.SharedMemory'
1070
+ | 'ES2024.String'
1071
+ | 'ESNext'
1072
+ | 'ESNext.Array'
1073
+ | 'ESNext.AsyncIterable'
1074
+ | 'ESNext.BigInt'
1075
+ | 'ESNext.Collection'
1076
+ | 'ESNext.Decorators'
1077
+ | 'ESNext.Disposable'
1078
+ | 'ESNext.Intl'
1079
+ | 'ESNext.Iterator'
1080
+ | 'ESNext.Promise'
1081
+ | 'ESNext.String'
1082
+ | 'ESNext.Symbol'
1083
+ | 'ESNext.WeakRef'
1084
+ | 'DOM'
1085
+ | 'DOM.Iterable'
1086
+ | 'ScriptHost'
1087
+ | 'WebWorker'
1088
+ | 'WebWorker.AsyncIterable'
1089
+ | 'WebWorker.ImportScripts'
1090
+ | 'WebWorker.Iterable'
1091
+ // Lowercase alternatives
1092
+ | 'es5'
1093
+ | 'es6'
1094
+ | 'es7'
1095
+ | 'es2015'
1096
+ | 'es2015.collection'
1097
+ | 'es2015.core'
1098
+ | 'es2015.generator'
1099
+ | 'es2015.iterable'
1100
+ | 'es2015.promise'
1101
+ | 'es2015.proxy'
1102
+ | 'es2015.reflect'
1103
+ | 'es2015.symbol.wellknown'
1104
+ | 'es2015.symbol'
1105
+ | 'es2016'
1106
+ | 'es2016.array.include'
1107
+ | 'es2017'
1108
+ | 'es2017.arraybuffer'
1109
+ | 'es2017.date'
1110
+ | 'es2017.intl'
1111
+ | 'es2017.object'
1112
+ | 'es2017.sharedmemory'
1113
+ | 'es2017.string'
1114
+ | 'es2017.typedarrays'
1115
+ | 'es2018'
1116
+ | 'es2018.asyncgenerator'
1117
+ | 'es2018.asynciterable'
1118
+ | 'es2018.intl'
1119
+ | 'es2018.promise'
1120
+ | 'es2018.regexp'
1121
+ | 'es2019'
1122
+ | 'es2019.array'
1123
+ | 'es2019.object'
1124
+ | 'es2019.string'
1125
+ | 'es2019.symbol'
1126
+ | 'es2020'
1127
+ | 'es2020.bigint'
1128
+ | 'es2020.promise'
1129
+ | 'es2020.string'
1130
+ | 'es2020.symbol.wellknown'
1131
+ | 'es2020.sharedmemory'
1132
+ | 'es2020.intl'
1133
+ | 'es2021'
1134
+ | 'es2021.intl'
1135
+ | 'es2021.promise'
1136
+ | 'es2021.string'
1137
+ | 'es2021.weakref'
1138
+ | 'es2022'
1139
+ | 'es2022.array'
1140
+ | 'es2022.error'
1141
+ | 'es2022.intl'
1142
+ | 'es2022.object'
1143
+ | 'es2022.regexp'
1144
+ | 'es2022.string'
1145
+ | 'es2023'
1146
+ | 'es2023.array'
1147
+ | 'es2023.collection'
1148
+ | 'es2023.intl'
1149
+ | 'es2024'
1150
+ | 'es2024.arraybuffer'
1151
+ | 'es2024.collection'
1152
+ | 'es2024.object'
1153
+ | 'es2024.promise'
1154
+ | 'es2024.regexp'
1155
+ | 'es2024.sharedmemory'
1156
+ | 'es2024.string'
1157
+ | 'esnext'
1158
+ | 'esnext.array'
1159
+ | 'esnext.asynciterable'
1160
+ | 'esnext.bigint'
1161
+ | 'esnext.collection'
1162
+ | 'esnext.decorators'
1163
+ | 'esnext.disposable'
1164
+ | 'esnext.intl'
1165
+ | 'esnext.iterator'
1166
+ | 'esnext.promise'
1167
+ | 'esnext.string'
1168
+ | 'esnext.symbol'
1169
+ | 'esnext.weakref'
1170
+ | 'dom'
1171
+ | 'dom.iterable'
1172
+ | 'scripthost'
1173
+ | 'webworker'
1174
+ | 'webworker.asynciterable'
1175
+ | 'webworker.importscripts'
1176
+ | 'webworker.iterable';
1177
+
1178
+ export type Plugin = {
1179
+ /**
1180
+ Plugin name.
1181
+ */
1182
+ name: string;
1183
+ };
1184
+
1185
+ export type ImportsNotUsedAsValues =
1186
+ | 'remove'
1187
+ | 'preserve'
1188
+ | 'error';
1189
+
1190
+ export type FallbackPolling =
1191
+ | 'fixedPollingInterval'
1192
+ | 'priorityPollingInterval'
1193
+ | 'dynamicPriorityPolling'
1194
+ | 'fixedInterval'
1195
+ | 'priorityInterval'
1196
+ | 'dynamicPriority'
1197
+ | 'fixedChunkSize';
1198
+
1199
+ export type WatchDirectory =
1200
+ | 'useFsEvents'
1201
+ | 'fixedPollingInterval'
1202
+ | 'dynamicPriorityPolling'
1203
+ | 'fixedChunkSizePolling';
1204
+
1205
+ export type WatchFile =
1206
+ | 'fixedPollingInterval'
1207
+ | 'priorityPollingInterval'
1208
+ | 'dynamicPriorityPolling'
1209
+ | 'useFsEvents'
1210
+ | 'useFsEventsOnParentDirectory'
1211
+ | 'fixedChunkSizePolling';
1212
+
1213
+ export type ModuleResolution =
1214
+ | 'classic'
1215
+ | 'node'
1216
+ | 'node10'
1217
+ | 'node16'
1218
+ | 'nodenext'
1219
+ | 'bundler'
1220
+ // Pascal-cased alternatives
1221
+ | 'Classic'
1222
+ | 'Node'
1223
+ | 'Node10'
1224
+ | 'Node16'
1225
+ | 'NodeNext'
1226
+ | 'Bundler';
1227
+
1228
+ export type ModuleDetection =
1229
+ | 'auto'
1230
+ | 'legacy'
1231
+ | 'force';
1232
+
1233
+ export type IgnoreDeprecations = '5.0';
1234
+ }
1235
+
1236
+ export type CompilerOptions = {
1237
+ /**
1238
+ The character set of the input files.
1239
+
1240
+ @default 'utf8'
1241
+ @deprecated This option will be removed in TypeScript 5.5.
1242
+ */
1243
+ charset?: string;
1244
+
1245
+ /**
1246
+ Enables building for project references.
1247
+
1248
+ @default true
1249
+ */
1250
+ composite?: boolean;
1251
+
1252
+ /**
1253
+ Generates corresponding d.ts files.
1254
+
1255
+ @default false
1256
+ */
1257
+ declaration?: boolean;
1258
+
1259
+ /**
1260
+ Specify output directory for generated declaration files.
1261
+ */
1262
+ declarationDir?: string;
1263
+
1264
+ /**
1265
+ Show diagnostic information.
1266
+
1267
+ @default false
1268
+ */
1269
+ diagnostics?: boolean;
1270
+
1271
+ /**
1272
+ Reduce the number of projects loaded automatically by TypeScript.
1273
+
1274
+ @default false
1275
+ */
1276
+ disableReferencedProjectLoad?: boolean;
1277
+
1278
+ /**
1279
+ Enforces using indexed accessors for keys declared using an indexed type.
1280
+
1281
+ @default false
1282
+ */
1283
+ noPropertyAccessFromIndexSignature?: boolean;
1284
+
1285
+ /**
1286
+ Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
1287
+
1288
+ @default false
1289
+ */
1290
+ emitBOM?: boolean;
1291
+
1292
+ /**
1293
+ Only emit `.d.ts` declaration files.
1294
+
1295
+ @default false
1296
+ */
1297
+ emitDeclarationOnly?: boolean;
1298
+
1299
+ /**
1300
+ Differentiate between undefined and not present when type checking.
1301
+
1302
+ @default false
1303
+ */
1304
+ exactOptionalPropertyTypes?: boolean;
1305
+
1306
+ /**
1307
+ Enable incremental compilation.
1308
+
1309
+ @default `composite`
1310
+ */
1311
+ incremental?: boolean;
1312
+
1313
+ /**
1314
+ Specify file to store incremental compilation information.
1315
+
1316
+ @default '.tsbuildinfo'
1317
+ */
1318
+ tsBuildInfoFile?: string;
1319
+
1320
+ /**
1321
+ Emit a single file with source maps instead of having a separate file.
1322
+
1323
+ @default false
1324
+ */
1325
+ inlineSourceMap?: boolean;
1326
+
1327
+ /**
1328
+ Emit the source alongside the sourcemaps within a single file.
1329
+
1330
+ Requires `--inlineSourceMap` to be set.
1331
+
1332
+ @default false
1333
+ */
1334
+ inlineSources?: boolean;
1335
+
1336
+ /**
1337
+ Specify what JSX code is generated.
1338
+
1339
+ @default 'preserve'
1340
+ */
1341
+ jsx?: CompilerOptions.JSX;
1342
+
1343
+ /**
1344
+ Specifies the object invoked for `createElement` and `__spread` when targeting `'react'` JSX emit.
1345
+
1346
+ @default 'React'
1347
+ */
1348
+ reactNamespace?: string;
1349
+
1350
+ /**
1351
+ Specify the JSX factory function to use when targeting React JSX emit, e.g. `React.createElement` or `h`.
1352
+
1353
+ @default 'React.createElement'
1354
+ */
1355
+ jsxFactory?: string;
1356
+
1357
+ /**
1358
+ Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
1359
+
1360
+ @default 'React.Fragment'
1361
+ */
1362
+ jsxFragmentFactory?: string;
1363
+
1364
+ /**
1365
+ Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.
1366
+
1367
+ @default 'react'
1368
+ */
1369
+ jsxImportSource?: string;
1370
+
1371
+ /**
1372
+ Print names of files part of the compilation.
1373
+
1374
+ @default false
1375
+ */
1376
+ listFiles?: boolean;
1377
+
1378
+ /**
1379
+ Specifies the location where debugger should locate map files instead of generated locations.
1380
+ */
1381
+ mapRoot?: string;
1382
+
1383
+ /**
1384
+ 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.
1385
+
1386
+ @default ['ES3', 'ES5'].includes(target) ? 'CommonJS' : 'ES6'
1387
+ */
1388
+ module?: CompilerOptions.Module;
1389
+
1390
+ /**
1391
+ Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6).
1392
+
1393
+ @default ['AMD', 'System', 'ES6'].includes(module) ? 'classic' : 'node'
1394
+ */
1395
+ moduleResolution?: CompilerOptions.ModuleResolution;
1396
+
1397
+ /**
1398
+ Specifies the end of line sequence to be used when emitting files: 'crlf' (Windows) or 'lf' (Unix).
1399
+
1400
+ @default 'LF'
1401
+ */
1402
+ newLine?: CompilerOptions.NewLine;
1403
+
1404
+ /**
1405
+ Disable full type checking (only critical parse and emit errors will be reported).
1406
+
1407
+ @default false
1408
+ */
1409
+ noCheck?: boolean;
1410
+
1411
+ /**
1412
+ Do not emit output.
1413
+
1414
+ @default false
1415
+ */
1416
+ noEmit?: boolean;
1417
+
1418
+ /**
1419
+ Do not generate custom helper functions like `__extends` in compiled output.
1420
+
1421
+ @default false
1422
+ */
1423
+ noEmitHelpers?: boolean;
1424
+
1425
+ /**
1426
+ Do not emit outputs if any type checking errors were reported.
1427
+
1428
+ @default false
1429
+ */
1430
+ noEmitOnError?: boolean;
1431
+
1432
+ /**
1433
+ Warn on expressions and declarations with an implied 'any' type.
1434
+
1435
+ @default false
1436
+ */
1437
+ noImplicitAny?: boolean;
1438
+
1439
+ /**
1440
+ Raise error on 'this' expressions with an implied any type.
1441
+
1442
+ @default false
1443
+ */
1444
+ noImplicitThis?: boolean;
1445
+
1446
+ /**
1447
+ Report errors on unused locals.
1448
+
1449
+ @default false
1450
+ */
1451
+ noUnusedLocals?: boolean;
1452
+
1453
+ /**
1454
+ Report errors on unused parameters.
1455
+
1456
+ @default false
1457
+ */
1458
+ noUnusedParameters?: boolean;
1459
+
1460
+ /**
1461
+ Do not include the default library file (lib.d.ts).
1462
+
1463
+ @default false
1464
+ */
1465
+ noLib?: boolean;
1466
+
1467
+ /**
1468
+ Do not add triple-slash references or module import targets to the list of compiled files.
1469
+
1470
+ @default false
1471
+ */
1472
+ noResolve?: boolean;
1473
+
1474
+ /**
1475
+ Disable strict checking of generic signatures in function types.
1476
+
1477
+ @default false
1478
+ @deprecated This option will be removed in TypeScript 5.5.
1479
+ */
1480
+ noStrictGenericChecks?: boolean;
1481
+
1482
+ /**
1483
+ @deprecated use `skipLibCheck` instead.
1484
+ */
1485
+ skipDefaultLibCheck?: boolean;
1486
+
1487
+ /**
1488
+ Skip type checking of declaration files.
1489
+
1490
+ @default false
1491
+ */
1492
+ skipLibCheck?: boolean;
1493
+
1494
+ /**
1495
+ Concatenate and emit output to single file.
1496
+ */
1497
+ outFile?: string;
1498
+
1499
+ /**
1500
+ Redirect output structure to the directory.
1501
+ */
1502
+ outDir?: string;
1503
+
1504
+ /**
1505
+ Do not erase const enum declarations in generated code.
1506
+
1507
+ @default false
1508
+ */
1509
+ preserveConstEnums?: boolean;
1510
+
1511
+ /**
1512
+ Do not resolve symlinks to their real path; treat a symlinked file like a real one.
1513
+
1514
+ @default false
1515
+ */
1516
+ preserveSymlinks?: boolean;
1517
+
1518
+ /**
1519
+ Keep outdated console output in watch mode instead of clearing the screen.
1520
+
1521
+ @default false
1522
+ */
1523
+ preserveWatchOutput?: boolean;
1524
+
1525
+ /**
1526
+ Stylize errors and messages using color and context (experimental).
1527
+
1528
+ @default true // Unless piping to another program or redirecting output to a file.
1529
+ */
1530
+ pretty?: boolean;
1531
+
1532
+ /**
1533
+ Do not emit comments to output.
1534
+
1535
+ @default false
1536
+ */
1537
+ removeComments?: boolean;
1538
+
1539
+ /**
1540
+ Specifies the root directory of input files.
1541
+
1542
+ Use to control the output directory structure with `--outDir`.
1543
+ */
1544
+ rootDir?: string;
1545
+
1546
+ /**
1547
+ Unconditionally emit imports for unresolved files.
1548
+
1549
+ @default false
1550
+ */
1551
+ isolatedModules?: boolean;
1552
+
1553
+ /**
1554
+ Require sufficient annotation on exports so other tools can trivially generate declaration files.
1555
+
1556
+ @default false
1557
+ */
1558
+ isolatedDeclarations?: boolean;
1559
+
1560
+ /**
1561
+ Generates corresponding '.map' file.
1562
+
1563
+ @default false
1564
+ */
1565
+ sourceMap?: boolean;
1566
+
1567
+ /**
1568
+ Specifies the location where debugger should locate TypeScript files instead of source locations.
1569
+ */
1570
+ sourceRoot?: string;
1571
+
1572
+ /**
1573
+ Suppress excess property checks for object literals.
1574
+
1575
+ @default false
1576
+ @deprecated This option will be removed in TypeScript 5.5.
1577
+ */
1578
+ suppressExcessPropertyErrors?: boolean;
1579
+
1580
+ /**
1581
+ Suppress noImplicitAny errors for indexing objects lacking index signatures.
1582
+
1583
+ @default false
1584
+ @deprecated This option will be removed in TypeScript 5.5.
1585
+ */
1586
+ suppressImplicitAnyIndexErrors?: boolean;
1587
+
1588
+
1589
+
1590
+ /**
1591
+ Specify ECMAScript target version.
1592
+
1593
+ @default 'es3'
1594
+ */
1595
+ target?: CompilerOptions.Target;
1596
+
1597
+ /**
1598
+ Default catch clause variables as `unknown` instead of `any`.
1599
+
1600
+ @default false
1601
+ */
1602
+ useUnknownInCatchVariables?: boolean;
1603
+
1604
+ /**
1605
+ Watch input files.
1606
+
1607
+ @default false
1608
+ @deprecated Use watchOptions instead.
1609
+ */
1610
+ watch?: boolean;
1611
+
1612
+ /**
1613
+ Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
1614
+
1615
+ @deprecated Use watchOptions.fallbackPolling instead.
1616
+ */
1617
+ fallbackPolling?: CompilerOptions.FallbackPolling;
1618
+
1619
+ /**
1620
+ Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
1621
+
1622
+ @default 'useFsEvents'
1623
+ @deprecated Use watchOptions.watchDirectory instead.
1624
+ */
1625
+ watchDirectory?: CompilerOptions.WatchDirectory;
1626
+
1627
+ /**
1628
+ Specify the strategy for watching individual files.
1629
+
1630
+ @default 'useFsEvents'
1631
+ @deprecated Use watchOptions.watchFile instead.
1632
+ */
1633
+ watchFile?: CompilerOptions.WatchFile;
1634
+
1635
+ /**
1636
+ Enables experimental support for ES7 decorators.
1637
+
1638
+ @default false
1639
+ */
1640
+ experimentalDecorators?: boolean;
1641
+
1642
+ /**
1643
+ Emit design-type metadata for decorated declarations in source.
1644
+
1645
+ @default false
1646
+ */
1647
+ emitDecoratorMetadata?: boolean;
1648
+
1649
+ /**
1650
+ Do not report errors on unused labels.
1651
+
1652
+ @default false
1653
+ */
1654
+ allowUnusedLabels?: boolean;
1655
+
1656
+ /**
1657
+ Report error when not all code paths in function return a value.
1658
+
1659
+ @default false
1660
+ */
1661
+ noImplicitReturns?: boolean;
1662
+
1663
+ /**
1664
+ Add `undefined` to a type when accessed using an index.
1665
+
1666
+ @default false
1667
+ */
1668
+ noUncheckedIndexedAccess?: boolean;
1669
+
1670
+ /**
1671
+ Report error if failed to find a source file for a side effect import.
1672
+
1673
+ @default false
1674
+ */
1675
+ noUncheckedSideEffectImports?: boolean;
1676
+
1677
+ /**
1678
+ Report errors for fallthrough cases in switch statement.
1679
+
1680
+ @default false
1681
+ */
1682
+ noFallthroughCasesInSwitch?: boolean;
1683
+
1684
+ /**
1685
+ Ensure overriding members in derived classes are marked with an override modifier.
1686
+
1687
+ @default false
1688
+ */
1689
+ noImplicitOverride?: boolean;
1690
+
1691
+ /**
1692
+ Do not report errors on unreachable code.
1693
+
1694
+ @default false
1695
+ */
1696
+ allowUnreachableCode?: boolean;
1697
+
1698
+ /**
1699
+ Disallow inconsistently-cased references to the same file.
1700
+
1701
+ @default true
1702
+ */
1703
+ forceConsistentCasingInFileNames?: boolean;
1704
+
1705
+ /**
1706
+ Emit a v8 CPU profile of the compiler run for debugging.
1707
+
1708
+ @default 'profile.cpuprofile'
1709
+ */
1710
+ generateCpuProfile?: string;
1711
+
1712
+ /**
1713
+ Generates an event trace and a list of types.
1714
+ */
1715
+ generateTrace?: boolean;
1716
+
1717
+ /**
1718
+ Base directory to resolve non-relative module names.
1719
+ */
1720
+ baseUrl?: string;
1721
+
1722
+ /**
1723
+ Specify path mapping to be computed relative to baseUrl option.
1724
+ */
1725
+ paths?: Record<string, string[]>;
1726
+
1727
+ /**
1728
+ List of TypeScript language server plugins to load.
1729
+ */
1730
+ plugins?: CompilerOptions.Plugin[];
1731
+
1732
+ /**
1733
+ Specify list of root directories to be used when resolving modules.
1734
+ */
1735
+ rootDirs?: string[];
1736
+
1737
+ /**
1738
+ Specify list of directories for type definition files to be included.
1739
+ */
1740
+ typeRoots?: string[];
1741
+
1742
+ /**
1743
+ Type declaration files to be included in compilation.
1744
+ */
1745
+ types?: string[];
1746
+
1747
+ /**
1748
+ Enable tracing of the name resolution process.
1749
+
1750
+ @default false
1751
+ */
1752
+ traceResolution?: boolean;
1753
+
1754
+ /**
1755
+ Allow javascript files to be compiled.
1756
+
1757
+ @default false
1758
+ */
1759
+ allowJs?: boolean;
1760
+
1761
+ /**
1762
+ Do not truncate error messages.
1763
+
1764
+ @default false
1765
+ */
1766
+ noErrorTruncation?: boolean;
1767
+
1768
+ /**
1769
+ Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
1770
+
1771
+ @default module === 'system' || esModuleInterop
1772
+ */
1773
+ allowSyntheticDefaultImports?: boolean;
1774
+
1775
+ /**
1776
+ Do not emit `'use strict'` directives in module output.
1777
+
1778
+ @default false
1779
+ @deprecated This option will be removed in TypeScript 5.5.
1780
+ */
1781
+ noImplicitUseStrict?: boolean;
1782
+
1783
+ /**
1784
+ Enable to list all emitted files.
1785
+
1786
+ @default false
1787
+ */
1788
+ listEmittedFiles?: boolean;
1789
+
1790
+ /**
1791
+ Disable size limit for JavaScript project.
1792
+
1793
+ @default false
1794
+ */
1795
+ disableSizeLimit?: boolean;
1796
+
1797
+ /**
1798
+ List of library files to be included in the compilation.
1799
+ */
1800
+ lib?: CompilerOptions.Lib[];
1801
+
1802
+ /**
1803
+ Enable strict null checks.
1804
+
1805
+ @default false
1806
+ */
1807
+ strictNullChecks?: boolean;
1808
+
1809
+ /**
1810
+ The maximum dependency depth to search under `node_modules` and load JavaScript files. Only applicable with `--allowJs`.
1811
+
1812
+ @default 0
1813
+ */
1814
+ maxNodeModuleJsDepth?: number;
1815
+
1816
+ /**
1817
+ Import emit helpers (e.g. `__extends`, `__rest`, etc..) from tslib.
1818
+
1819
+ @default false
1820
+ */
1821
+ importHelpers?: boolean;
1822
+
1823
+ /**
1824
+ Specify emit/checking behavior for imports that are only used for types.
1825
+
1826
+ @default 'remove'
1827
+ @deprecated Use `verbatimModuleSyntax` instead.
1828
+ */
1829
+ importsNotUsedAsValues?: CompilerOptions.ImportsNotUsedAsValues;
1830
+
1831
+ /**
1832
+ Parse in strict mode and emit `'use strict'` for each source file.
1833
+
1834
+ @default false
1835
+ */
1836
+ alwaysStrict?: boolean;
1837
+
1838
+ /**
1839
+ Enable all strict type checking options.
1840
+
1841
+ @default false
1842
+ */
1843
+ strict?: boolean;
1844
+
1845
+ /**
1846
+ Enable stricter checking of of the `bind`, `call`, and `apply` methods on functions.
1847
+
1848
+ @default false
1849
+ */
1850
+ strictBindCallApply?: boolean;
1851
+
1852
+ /**
1853
+ Provide full support for iterables in `for-of`, spread, and destructuring when targeting `ES5` or `ES3`.
1854
+
1855
+ @default false
1856
+ */
1857
+ downlevelIteration?: boolean;
1858
+
1859
+ /**
1860
+ Report errors in `.js` files.
1861
+
1862
+ @default false
1863
+ */
1864
+ checkJs?: boolean;
1865
+
1866
+ /**
1867
+ Built-in iterators are instantiated with a `TReturn` type of undefined instead of `any`.
1868
+
1869
+ @default false
1870
+ */
1871
+ strictBuiltinIteratorReturn?: boolean;
1872
+
1873
+ /**
1874
+ Disable bivariant parameter checking for function types.
1875
+
1876
+ @default false
1877
+ */
1878
+ strictFunctionTypes?: boolean;
1879
+
1880
+ /**
1881
+ Ensure non-undefined class properties are initialized in the constructor.
1882
+
1883
+ @default false
1884
+ */
1885
+ strictPropertyInitialization?: boolean;
1886
+
1887
+ /**
1888
+ Emit `__importStar` and `__importDefault` helpers for runtime Babel ecosystem compatibility and enable `--allowSyntheticDefaultImports` for typesystem compatibility.
1889
+
1890
+ @default false
1891
+ */
1892
+ esModuleInterop?: boolean;
1893
+
1894
+ /**
1895
+ Allow accessing UMD globals from modules.
1896
+
1897
+ @default false
1898
+ */
1899
+ allowUmdGlobalAccess?: boolean;
1900
+
1901
+ /**
1902
+ Resolve `keyof` to string valued property names only (no numbers or symbols).
1903
+
1904
+ @default false
1905
+ @deprecated This option will be removed in TypeScript 5.5.
1906
+ */
1907
+ keyofStringsOnly?: boolean;
1908
+
1909
+ /**
1910
+ Emit ECMAScript standard class fields.
1911
+
1912
+ @default false
1913
+ */
1914
+ useDefineForClassFields?: boolean;
1915
+
1916
+ /**
1917
+ Generates a sourcemap for each corresponding `.d.ts` file.
1918
+
1919
+ @default false
1920
+ */
1921
+ declarationMap?: boolean;
1922
+
1923
+ /**
1924
+ Include modules imported with `.json` extension.
1925
+
1926
+ @default false
1927
+ */
1928
+ resolveJsonModule?: boolean;
1929
+
1930
+ /**
1931
+ Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.
1932
+
1933
+ @default false
1934
+ */
1935
+ assumeChangesOnlyAffectDirectDependencies?: boolean;
1936
+
1937
+ /**
1938
+ Output more detailed compiler performance information after building.
1939
+
1940
+ @default false
1941
+ */
1942
+ extendedDiagnostics?: boolean;
1943
+
1944
+ /**
1945
+ Print names of files that are part of the compilation and then stop processing.
1946
+
1947
+ @default false
1948
+ */
1949
+ listFilesOnly?: boolean;
1950
+
1951
+ /**
1952
+ Disable preferring source files instead of declaration files when referencing composite projects.
1953
+
1954
+ @default true if composite, false otherwise
1955
+ */
1956
+ disableSourceOfProjectReferenceRedirect?: boolean;
1957
+
1958
+ /**
1959
+ Opt a project out of multi-project reference checking when editing.
1960
+
1961
+ @default false
1962
+ */
1963
+ disableSolutionSearching?: boolean;
1964
+
1965
+ /**
1966
+ Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.
1967
+
1968
+ @default false
1969
+ */
1970
+ explainFiles?: boolean;
1971
+
1972
+ /**
1973
+ Preserve unused imported values in the JavaScript output that would otherwise be removed.
1974
+
1975
+ @default true
1976
+ @deprecated Use `verbatimModuleSyntax` instead.
1977
+ */
1978
+ preserveValueImports?: boolean;
1979
+
1980
+ /**
1981
+ List of file name suffixes to search when resolving a module.
1982
+ */
1983
+ moduleSuffixes?: string[];
1984
+
1985
+ /**
1986
+ Control what method is used to detect module-format JS files.
1987
+
1988
+ @default 'auto'
1989
+ */
1990
+ moduleDetection?: CompilerOptions.ModuleDetection;
1991
+
1992
+ /**
1993
+ Allows TypeScript files to import each other with a TypeScript-specific extension like .ts, .mts, or .tsx.
1994
+
1995
+ @default false
1996
+ */
1997
+ allowImportingTsExtensions?: boolean;
1998
+
1999
+ /**
2000
+ Forces TypeScript to consult the exports field of package.json files if it ever reads from a package in node_modules.
2001
+
2002
+ @default false
2003
+ */
2004
+ resolvePackageJsonExports?: boolean;
2005
+
2006
+ /**
2007
+ 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.
2008
+
2009
+ @default false
2010
+ */
2011
+ resolvePackageJsonImports?: boolean;
2012
+
2013
+ /**
2014
+ Suppress errors for file formats that TypeScript does not understand.
2015
+
2016
+ @default false
2017
+ */
2018
+ allowArbitraryExtensions?: boolean;
2019
+
2020
+ /**
2021
+ List of additional conditions that should succeed when TypeScript resolves from package.json.
2022
+ */
2023
+ customConditions?: string[];
2024
+
2025
+ /**
2026
+ Anything that uses the type modifier is dropped entirely.
2027
+
2028
+ @default false
2029
+ */
2030
+ verbatimModuleSyntax?: boolean;
2031
+
2032
+ /**
2033
+ Suppress deprecation warnings
2034
+ */
2035
+ ignoreDeprecations?: CompilerOptions.IgnoreDeprecations;
2036
+
2037
+ /**
2038
+ Do not allow runtime constructs that are not part of ECMAScript.
2039
+
2040
+ @default false
2041
+ */
2042
+ erasableSyntaxOnly?: boolean;
2043
+
2044
+ /**
2045
+ Enable lib replacement.
2046
+
2047
+ @default true
2048
+ */
2049
+ libReplacement?: boolean;
2050
+ };
2051
+
2052
+ namespace WatchOptions {
2053
+ export type WatchFileKind =
2054
+ | 'FixedPollingInterval'
2055
+ | 'PriorityPollingInterval'
2056
+ | 'DynamicPriorityPolling'
2057
+ | 'FixedChunkSizePolling'
2058
+ | 'UseFsEvents'
2059
+ | 'UseFsEventsOnParentDirectory';
2060
+
2061
+ export type WatchDirectoryKind =
2062
+ | 'UseFsEvents'
2063
+ | 'FixedPollingInterval'
2064
+ | 'DynamicPriorityPolling'
2065
+ | 'FixedChunkSizePolling';
2066
+
2067
+ export type PollingWatchKind =
2068
+ | 'FixedInterval'
2069
+ | 'PriorityInterval'
2070
+ | 'DynamicPriority'
2071
+ | 'FixedChunkSize';
2072
+ }
2073
+
2074
+ export type WatchOptions = {
2075
+
2076
+ /**
2077
+ Specify the strategy for watching individual files.
2078
+
2079
+ @default 'UseFsEvents'
2080
+ */
2081
+ watchFile?: WatchOptions.WatchFileKind | Lowercase<WatchOptions.WatchFileKind>;
2082
+
2083
+ /**
2084
+ Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
2085
+
2086
+ @default 'UseFsEvents'
2087
+ */
2088
+ watchDirectory?: WatchOptions.WatchDirectoryKind | Lowercase<WatchOptions.WatchDirectoryKind>;
2089
+
2090
+ /**
2091
+ Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
2092
+ */
2093
+ fallbackPolling?: WatchOptions.PollingWatchKind | Lowercase<WatchOptions.PollingWatchKind>;
2094
+
2095
+ /**
2096
+ Enable synchronous updates on directory watchers for platforms that don't support recursive watching natively.
2097
+ */
2098
+ synchronousWatchDirectory?: boolean;
2099
+
2100
+ /**
2101
+ Specifies a list of directories to exclude from watch.
2102
+ */
2103
+ excludeDirectories?: string[];
2104
+
2105
+ /**
2106
+ Specifies a list of files to exclude from watch.
2107
+ */
2108
+ excludeFiles?: string[];
2109
+ };
2110
+
2111
+ /**
2112
+ Auto type (.d.ts) acquisition options for this project.
2113
+ */
2114
+ export type TypeAcquisition = {
2115
+ /**
2116
+ Enable auto type acquisition.
2117
+ */
2118
+ enable?: boolean;
2119
+
2120
+ /**
2121
+ Specifies a list of type declarations to be included in auto type acquisition. For example, `['jquery', 'lodash']`.
2122
+ */
2123
+ include?: string[];
2124
+
2125
+ /**
2126
+ Specifies a list of type declarations to be excluded from auto type acquisition. For example, `['jquery', 'lodash']`.
2127
+ */
2128
+ exclude?: string[];
2129
+
2130
+ /**
2131
+ Disable infering what types should be added based on filenames in a project.
2132
+ */
2133
+ disableFilenameBasedTypeAcquisition?: boolean;
2134
+ };
2135
+
2136
+ export type References = {
2137
+ /**
2138
+ A normalized path on disk.
2139
+ */
2140
+ path: string;
2141
+
2142
+ /**
2143
+ The path as the user originally wrote it.
2144
+ */
2145
+ originalPath?: string;
2146
+
2147
+ /**
2148
+ True if the output of this reference should be prepended to the output of this project.
2149
+
2150
+ Only valid for `--outFile` compilations.
2151
+ @deprecated This option will be removed in TypeScript 5.5.
2152
+ */
2153
+ prepend?: boolean;
2154
+
2155
+ /**
2156
+ True if it is intended that this reference form a circularity.
2157
+ */
2158
+ circular?: boolean;
2159
+ };
2160
+ }
2161
+
2162
+ /**
2163
+ Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) (TypeScript 3.7).
2164
+
2165
+ @category File
2166
+ */
2167
+ type TsConfigJson = {
2168
+ /**
2169
+ Instructs the TypeScript compiler how to compile `.ts` files.
2170
+ */
2171
+ compilerOptions?: TsConfigJson.CompilerOptions;
2172
+
2173
+ /**
2174
+ Instructs the TypeScript compiler how to watch files.
2175
+ */
2176
+ watchOptions?: TsConfigJson.WatchOptions;
2177
+
2178
+ /**
2179
+ Auto type (.d.ts) acquisition options for this project.
2180
+ */
2181
+ typeAcquisition?: TsConfigJson.TypeAcquisition;
2182
+
2183
+ /**
2184
+ Enable Compile-on-Save for this project.
2185
+ */
2186
+ compileOnSave?: boolean;
2187
+
2188
+ /**
2189
+ Path to base configuration file to inherit from.
2190
+ */
2191
+ extends?: string | string[];
2192
+
2193
+ /**
2194
+ 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.
2195
+ */
2196
+ files?: string[];
2197
+
2198
+ /**
2199
+ 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.
2200
+
2201
+ Glob patterns require TypeScript version 2.0 or later.
2202
+ */
2203
+ exclude?: string[];
2204
+
2205
+ /**
2206
+ Specifies a list of glob patterns that match files to be included in compilation.
2207
+
2208
+ 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`.
2209
+ */
2210
+ include?: string[];
2211
+
2212
+ /**
2213
+ Referenced projects.
2214
+ */
2215
+ references?: TsConfigJson.References[];
2216
+ };
2217
+
2218
+ type TsConfigJsonResolved = Except<TsConfigJson, "extends">;
2219
+ type TsConfigResult = {
2220
+ config: TsConfigJsonResolved;
2221
+ path: string;
2222
+ };
2223
+
2224
+ type HookCallback = (...arguments_: any) => Promise<void> | void;
2225
+ type HookKeys<T> = keyof T & string;
2226
+ type DeprecatedHook<T> = {
2227
+ message?: string;
2228
+ to: HookKeys<T>;
2229
+ };
2230
+ type ValueOf<C> = C extends Record<any, any> ? C[keyof C] : never;
2231
+ type Strings<T> = Exclude<keyof T, number | symbol>;
2232
+ type KnownKeys<T> = keyof {
2233
+ [K in keyof T as string extends K ? never : number extends K ? never : K]: never;
2234
+ };
2235
+ type StripGeneric<T> = Pick<T, KnownKeys<T> extends keyof T ? KnownKeys<T> : never>;
2236
+ type OnlyGeneric<T> = Omit<T, KnownKeys<T> extends keyof T ? KnownKeys<T> : never>;
2237
+ type Namespaces<T> = ValueOf<{
2238
+ [key in Strings<T>]: key extends `${infer Namespace}:${string}` ? Namespace : never;
2239
+ }>;
2240
+ type BareHooks<T> = ValueOf<{
2241
+ [key in Strings<T>]: key extends `${string}:${string}` ? never : key;
2242
+ }>;
2243
+ type HooksInNamespace<T, Namespace extends string> = ValueOf<{
2244
+ [key in Strings<T>]: key extends `${Namespace}:${infer HookName}` ? HookName : never;
2245
+ }>;
2246
+ type WithoutNamespace<T, Namespace extends string> = {
2247
+ [key in HooksInNamespace<T, Namespace>]: `${Namespace}:${key}` extends keyof T ? T[`${Namespace}:${key}`] : never;
2248
+ };
2249
+ type NestedHooks<T> = (Partial<StripGeneric<T>> | Partial<OnlyGeneric<T>>) & Partial<{
2250
+ [key in Namespaces<StripGeneric<T>>]: NestedHooks<WithoutNamespace<T, key>>;
2251
+ }> & Partial<{
2252
+ [key in BareHooks<StripGeneric<T>>]: T[key];
2253
+ }>;
2254
+
2255
+ type InferCallback<HT, HN extends keyof HT> = HT[HN] extends HookCallback ? HT[HN] : never;
2256
+ type InferSpyEvent<HT extends Record<string, any>> = {
2257
+ [key in keyof HT]: {
2258
+ name: key;
2259
+ args: Parameters<HT[key]>;
2260
+ context: Record<string, any>;
2261
+ };
2262
+ }[keyof HT];
2263
+ declare class Hookable<HooksT extends Record<string, any> = Record<string, HookCallback>, HookNameT extends HookKeys<HooksT> = HookKeys<HooksT>> {
2264
+ private _hooks;
2265
+ private _before?;
2266
+ private _after?;
2267
+ private _deprecatedHooks;
2268
+ private _deprecatedMessages?;
2269
+ constructor();
2270
+ hook<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>, options?: {
2271
+ allowDeprecated?: boolean;
2272
+ }): () => void;
2273
+ hookOnce<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>): () => void;
2274
+ removeHook<NameT extends HookNameT>(name: NameT, function_: InferCallback<HooksT, NameT>): void;
2275
+ deprecateHook<NameT extends HookNameT>(name: NameT, deprecated: HookKeys<HooksT> | DeprecatedHook<HooksT>): void;
2276
+ deprecateHooks(deprecatedHooks: Partial<Record<HookNameT, DeprecatedHook<HooksT>>>): void;
2277
+ addHooks(configHooks: NestedHooks<HooksT>): () => void;
2278
+ removeHooks(configHooks: NestedHooks<HooksT>): void;
2279
+ removeAllHooks(): void;
2280
+ callHook<NameT extends HookNameT>(name: NameT, ...arguments_: Parameters<InferCallback<HooksT, NameT>>): Promise<any>;
2281
+ callHookParallel<NameT extends HookNameT>(name: NameT, ...arguments_: Parameters<InferCallback<HooksT, NameT>>): Promise<any[]>;
2282
+ callHookWith<NameT extends HookNameT, CallFunction extends (hooks: HookCallback[], arguments_: Parameters<InferCallback<HooksT, NameT>>) => any>(caller: CallFunction, name: NameT, ...arguments_: Parameters<InferCallback<HooksT, NameT>>): ReturnType<CallFunction>;
2283
+ beforeEach(function_: (event: InferSpyEvent<HooksT>) => void): () => void;
2284
+ afterEach(function_: (event: InferSpyEvent<HooksT>) => void): () => void;
2285
+ }
2286
+
2287
+ /**
2288
+ * Jiti instance
2289
+ *
2290
+ * Calling `jiti()` is similar to CommonJS {@linkcode require()} but adds
2291
+ * extra features such as TypeScript and ESM compatibility.
2292
+ *
2293
+ * **Note:** It is recommended to use
2294
+ * {@linkcode Jiti.import | await jiti.import()} instead.
2295
+ */
2296
+ interface Jiti extends NodeRequire {
2297
+ /**
2298
+ * Resolved options
2299
+ */
2300
+ options: JitiOptions;
2301
+
2302
+ /**
2303
+ * ESM import a module with additional TypeScript and ESM compatibility.
2304
+ *
2305
+ * If you need the default export of module, you can use
2306
+ * `jiti.import(id, { default: true })` as shortcut to `mod?.default ?? mod`.
2307
+ */
2308
+ import<T = unknown>(
2309
+ id: string,
2310
+ opts?: JitiResolveOptions & { default?: true },
2311
+ ): Promise<T>;
2312
+
2313
+ /**
2314
+ * Resolve with ESM import conditions.
2315
+ */
2316
+ esmResolve(id: string, parentURL?: string): string;
2317
+ esmResolve<T extends JitiResolveOptions = JitiResolveOptions>(
2318
+ id: string,
2319
+ opts?: T,
2320
+ ): T["try"] extends true ? string | undefined : string;
2321
+
2322
+ /**
2323
+ * Transform source code
2324
+ */
2325
+ transform: (opts: TransformOptions) => string;
2326
+
2327
+ /**
2328
+ * Evaluate transformed code as a module
2329
+ */
2330
+ evalModule: (source: string, options?: EvalModuleOptions) => unknown;
2331
+ }
2332
+
2333
+ /**
2334
+ * Jiti instance options
2335
+ */
2336
+ interface JitiOptions {
2337
+ /**
2338
+ * Filesystem source cache
2339
+ *
2340
+ * An string can be passed to set the custom cache directory.
2341
+ *
2342
+ * By default (when set to `true`), jiti uses
2343
+ * `node_modules/.cache/jiti` (if exists) or `{TMP_DIR}/jiti`.
2344
+ *
2345
+ * This option can also be disabled using
2346
+ * `JITI_FS_CACHE=false` environment variable.
2347
+ *
2348
+ * **Note:** It is recommended to keep this option
2349
+ * enabled for better performance.
2350
+ *
2351
+ * @default true
2352
+ */
2353
+ fsCache?: boolean | string;
2354
+
2355
+ /**
2356
+ * Rebuild the filesystem source cache
2357
+ *
2358
+ * This option can also be enabled using
2359
+ * `JITI_REBUILD_FS_CACHE=true` environment variable.
2360
+ *
2361
+ * @default false
2362
+ */
2363
+ rebuildFsCache?: boolean;
2364
+
2365
+ /**
2366
+ * @deprecated Use the {@linkcode fsCache} option.
2367
+ *
2368
+ * @default true
2369
+ */
2370
+ cache?: boolean | string;
2371
+
2372
+ /**
2373
+ * Runtime module cache
2374
+ *
2375
+ * Disabling allows editing code and importing same module multiple times.
2376
+ *
2377
+ * When enabled, jiti integrates with Node.js native CommonJS cache store.
2378
+ *
2379
+ * This option can also be disabled using
2380
+ * `JITI_MODULE_CACHE=false` environment variable.
2381
+ *
2382
+ * @default true
2383
+ */
2384
+ moduleCache?: boolean;
2385
+
2386
+ /**
2387
+ * @deprecated Use the {@linkcode moduleCache} option.
2388
+ *
2389
+ * @default true
2390
+ */
2391
+ requireCache?: boolean;
2392
+
2393
+ /**
2394
+ * Custom transform function
2395
+ */
2396
+ transform?: (opts: TransformOptions) => TransformResult;
2397
+
2398
+ /**
2399
+ * Enable verbose debugging.
2400
+ *
2401
+ * Can also be enabled using `JITI_DEBUG=1` environment variable.
2402
+ *
2403
+ * @default false
2404
+ */
2405
+ debug?: boolean;
2406
+
2407
+ /**
2408
+ * Enable sourcemaps for transformed code.
2409
+ *
2410
+ * Can also be disabled using `JITI_SOURCE_MAPS=0` environment variable.
2411
+ *
2412
+ * @default false
2413
+ */
2414
+ sourceMaps?: boolean;
2415
+
2416
+ /**
2417
+ * Jiti combines module exports with the `default` export using an
2418
+ * internal Proxy to improve compatibility with mixed CJS/ESM usage.
2419
+ * You can check the current implementation
2420
+ * {@link https://github.com/unjs/jiti/blob/main/src/utils.ts#L105 here}.
2421
+ *
2422
+ * Can be disabled using `JITI_INTEROP_DEFAULT=0` environment variable.
2423
+ *
2424
+ * @default true
2425
+ */
2426
+ interopDefault?: boolean;
2427
+
2428
+
2429
+
2430
+ /**
2431
+ * Supported extensions to resolve.
2432
+ *
2433
+ * @default [".js", ".mjs", ".cjs", ".ts", ".tsx", ".mts", ".cts", ".mtsx", ".ctsx", ".json"]
2434
+ */
2435
+ extensions?: string[];
2436
+
2437
+ /**
2438
+ * Transform options
2439
+ */
2440
+ transformOptions?: Omit<TransformOptions, "source">;
2441
+
2442
+ /**
2443
+ * Resolve aliases
2444
+ *
2445
+ * You can use `JITI_ALIAS` environment variable to set aliases as
2446
+ * a JSON string.
2447
+ *
2448
+ * @default {}
2449
+ */
2450
+ alias?: Record<string, string>;
2451
+
2452
+ /**
2453
+ * List of modules (within `node_modules`) to always use native
2454
+ * require/import for them.
2455
+ *
2456
+ * You can use `JITI_NATIVE_MODULES` environment variable to set
2457
+ * native modules as a JSON string.
2458
+ *
2459
+ * @default []
2460
+ */
2461
+ nativeModules?: string[];
2462
+
2463
+ /**
2464
+ * List of modules (within `node_modules`) to transform them
2465
+ * regardless of syntax.
2466
+ *
2467
+ * You can use `JITI_TRANSFORM_MODULES` environment variable to set
2468
+ * transform modules as a JSON string.
2469
+ *
2470
+ * @default []
2471
+ */
2472
+ transformModules?: string[];
2473
+
2474
+ /**
2475
+ * Parent module's {@linkcode ImportMeta | import.meta} context to use
2476
+ * for ESM resolution.
2477
+ *
2478
+ * (Only used for `jiti/native` import)
2479
+ */
2480
+ importMeta?: ImportMeta;
2481
+
2482
+ /**
2483
+ * Try to use native require and import without jiti transformations first.
2484
+ *
2485
+ * Enabled if Bun is detected.
2486
+ *
2487
+ * @default false
2488
+ */
2489
+ tryNative?: boolean;
2490
+
2491
+ /**
2492
+ * Enable JSX support Enable JSX support using
2493
+ * {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx | `@babel/plugin-transform-react-jsx`}.
2494
+ *
2495
+ * You can also use `JITI_JSX=1` environment variable to enable JSX support.
2496
+ *
2497
+ * @default false
2498
+ */
2499
+ jsx?: boolean | JSXOptions;
2500
+ }
2501
+
2502
+ interface NodeRequire {
2503
+ /**
2504
+ * Module cache
2505
+ */
2506
+ cache: ModuleCache;
2507
+
2508
+ /**
2509
+ * @deprecated Prefer {@linkcode Jiti.import | await jiti.import()}
2510
+ * for better compatibility.
2511
+ */
2512
+ (id: string): any;
2513
+
2514
+ /**
2515
+ * @deprecated Prefer {@linkcode Jiti.esmResolve | jiti.esmResolve}
2516
+ * for better compatibility.
2517
+ */
2518
+ resolve: {
2519
+ /** @deprecated */
2520
+ (id: string, options?: { paths?: string[] | undefined }): string;
2521
+ /** @deprecated */
2522
+ paths(request: string): string[] | null;
2523
+ };
2524
+
2525
+ /** @deprecated CommonJS API */
2526
+ extensions: Record<
2527
+ ".js" | ".json" | ".node",
2528
+ (m: NodeModule, filename: string) => any | undefined
2529
+ >;
2530
+
2531
+ /** @deprecated CommonJS API */
2532
+ main: NodeModule | undefined;
2533
+ }
2534
+
2535
+ interface NodeModule {
2536
+ /**
2537
+ * `true` if the module is running during the Node.js preload.
2538
+ */
2539
+ isPreloading: boolean;
2540
+ exports: any;
2541
+ require: NodeRequire;
2542
+ id: string;
2543
+ filename: string;
2544
+ loaded: boolean;
2545
+ /**
2546
+ * @deprecated since Node.js **v14.6.0** Please use
2547
+ * {@linkcode NodeRequire.main | require.main} and
2548
+ * {@linkcode NodeModule.children | module.children} instead.
2549
+ */
2550
+ parent: NodeModule | null | undefined;
2551
+ children: NodeModule[];
2552
+ /**
2553
+ * The directory name of the module.
2554
+ * This is usually the same as the `path.dirname()` of the `module.id`.
2555
+ *
2556
+ * @since Node.js **v11.14.0**
2557
+ */
2558
+ path: string;
2559
+ paths: string[];
2560
+ }
2561
+
2562
+ type ModuleCache = Record<string, NodeModule>;
2563
+
2564
+ type EvalModuleOptions = Partial<{
2565
+ id: string;
2566
+ filename: string;
2567
+ ext: string;
2568
+ cache: ModuleCache;
2569
+ /**
2570
+ * @default true
2571
+ */
2572
+ async: boolean;
2573
+ forceTranspile: boolean;
2574
+ }>;
2575
+
2576
+ interface TransformOptions {
2577
+ source: string;
2578
+ filename?: string;
2579
+ ts?: boolean;
2580
+ retainLines?: boolean;
2581
+ interopDefault?: boolean;
2582
+ /**
2583
+ * @default false
2584
+ */
2585
+ async?: boolean;
2586
+ /**
2587
+ * @default false
2588
+ */
2589
+ jsx?: boolean | JSXOptions;
2590
+ babel?: Record<string, any>;
2591
+ }
2592
+
2593
+ interface TransformResult {
2594
+ code: string;
2595
+ error?: any;
2596
+ }
2597
+
2598
+ interface JitiResolveOptions {
2599
+ conditions?: string[];
2600
+ parentURL?: string | URL;
2601
+ try?: boolean;
2602
+ }
2603
+
2604
+ /**
2605
+ * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options | Reference}
2606
+ */
2607
+ interface JSXOptions {
2608
+ throwIfNamespace?: boolean;
2609
+ runtime?: "classic" | "automatic";
2610
+ importSource?: string;
2611
+ pragma?: string;
2612
+ pragmaFrag?: string;
2613
+ useBuiltIns?: boolean;
2614
+ useSpread?: boolean;
2615
+ }
2616
+
2617
+ type Environment = "production" | "development" | undefined;
2618
+ type Mode = "build" | "jit" | "watch";
2619
+ type Format = "cjs" | "esm";
2620
+ type Runtime = "browser" | "bun" | "deno" | "edge-light" | "electron" | "node" | "react-native" | "react-server" | "workerd" | undefined;
2621
+
2622
+ interface BuildHooks<T> {
2623
+ "build:before": (context: BuildContext<T>) => Promise<void> | void;
2624
+ "build:done": (context: BuildContext<T>) => Promise<void> | void;
2625
+ "build:prepare": (context: BuildContext<T>) => Promise<void> | void;
2626
+ "builder:before": (name: string, context: BuildContext<T>) => Promise<void> | void;
2627
+ "builder:done": (name: string, context: BuildContext<T>) => Promise<void> | void;
2628
+ "rollup:build": (context: BuildContext<T>, build: RollupBuild) => Promise<void> | void;
2629
+ "rollup:done": (context: BuildContext<T>) => Promise<void> | void;
2630
+ "rollup:dts:build": (context: BuildContext<T>, build: RollupBuild) => Promise<void> | void;
2631
+ "rollup:dts:done": (context: BuildContext<T>) => Promise<void> | void;
2632
+ "rollup:dts:options": (context: BuildContext<T>, options: RollupOptions) => Promise<void> | void;
2633
+ "rollup:options": (context: BuildContext<T>, options: RollupOptions) => Promise<void> | void;
2634
+ "rollup:watch": (context: BuildContext<T>, watcher: RollupWatcher) => Promise<void> | void;
2635
+ "typedoc:before": (context: BuildContext<T>) => Promise<void> | void;
2636
+ "typedoc:done": (context: BuildContext<T>) => Promise<void> | void;
2637
+ "validate:before": (context: BuildContext<T>) => Promise<void> | void;
2638
+ "validate:done": (context: BuildContext<T>) => Promise<void> | void;
2639
+ }
2640
+ type BuildContext<T> = {
2641
+ buildEntries: (BuildContextBuildAssetAndChunk | BuildContextBuildEntry)[];
2642
+ dependencyGraphMap: Map<string, Set<[string, string]>>;
2643
+ environment: Environment;
2644
+ hoistedDependencies: Set<string>;
2645
+ hooks: Hookable<BuildHooks<T>>;
2646
+ implicitDependencies: Set<string>;
2647
+ jiti: Jiti;
2648
+ logger: PailServerType$1;
2649
+ mode: Mode;
2650
+ options: T;
2651
+ pkg: PackageJson;
2652
+ tsconfig?: TsConfigResult;
2653
+ usedDependencies: Set<string>;
2654
+ warnings: Set<string>;
2655
+ };
2656
+ type BuildContextBuildAssetAndChunk = {
2657
+ chunk?: boolean;
2658
+ chunks?: string[];
2659
+ dynamicImports?: string[];
2660
+ exports?: string[];
2661
+ modules?: {
2662
+ bytes: number;
2663
+ id: string;
2664
+ }[];
2665
+ path: string;
2666
+ size?: {
2667
+ brotli?: number;
2668
+ bytes?: number;
2669
+ gzip?: number;
2670
+ };
2671
+ type?: "asset" | "chunk";
2672
+ };
2673
+ type BuildContextBuildEntry = {
2674
+ chunk?: boolean;
2675
+ chunks?: string[];
2676
+ dynamicImports?: string[];
2677
+ exports?: string[];
2678
+ modules?: {
2679
+ bytes: number;
2680
+ id: string;
2681
+ }[];
2682
+ path: string;
2683
+ size?: {
2684
+ brotli?: number;
2685
+ bytes?: number;
2686
+ gzip?: number;
2687
+ };
2688
+ type?: "entry";
2689
+ };
2690
+
18
2691
  type AnsiColors = "bgBlack" | "bgBlackBright" | "bgBlue" | "bgBlueBright" | "bgCyan" | "bgCyanBright" | "bgGray" | "bgGreen" | "bgGreenBright" | "bgGrey" | "bgMagenta" | "bgMagentaBright" | "bgRed" | "bgRedBright" | "bgWhite" | "bgWhiteBright" | "bgYellow" | "bgYellowBright" | "black" | "blackBright" | "blue" | "blueBright" | "cyan" | "cyanBright" | "gray" | "green" | "greenBright" | "grey" | "magenta" | "magentaBright" | "red" | "redBright" | "white" | "whiteBright" | "yellow" | "yellowBright";
19
2692
 
20
2693
  /**
@@ -282,35 +2955,26 @@ type SingleTargetDesc = {
282
2955
  src: string[] | string;
283
2956
  };
284
2957
 
285
- interface EsmShimCjsSyntaxOptions {
2958
+ type DataUriPluginOptions = {
286
2959
  exclude?: FilterPattern;
287
2960
  include?: FilterPattern;
2961
+ srcset?: boolean;
2962
+ };
2963
+
2964
+ interface DebarrelPluginOptions {
2965
+ include?: FilterPattern;
2966
+ possibleBarrelFiles?: (RegExp | string)[];
288
2967
  }
289
2968
 
290
- declare global {
291
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
292
- interface SymbolConstructor {
293
- readonly observable: symbol;
294
- }
2969
+ interface EsmShimCjsSyntaxOptions {
2970
+ exclude?: FilterPattern;
2971
+ include?: FilterPattern;
295
2972
  }
296
2973
 
297
- type MarkOptional<Type, Keys extends keyof Type> = Type extends Type ? Omit<Type, Keys> & Partial<Pick<Type, Keys>> : never;
298
- type EsbuildPluginConfig = Options$1 & {
299
- logger: PailServerType;
300
- };
301
- type OptimizeDepsOptions = {
302
- cwd: string;
303
- esbuildOptions?: BuildOptions;
304
- exclude?: string[];
305
- include: string[];
306
- sourceMap: boolean;
307
- };
308
- type Options$1 = Omit<TransformOptions, "loader" | "sourcemap"> & {
2974
+ type IsolatedDeclarationsOptions = {
309
2975
  exclude?: FilterPattern;
2976
+ ignoreErrors?: boolean;
310
2977
  include?: FilterPattern;
311
- loaders?: Record<string, Loader | false>;
312
- optimizeDeps?: MarkOptional<OptimizeDepsOptions, "cwd" | "sourceMap">;
313
- sourceMap?: boolean;
314
2978
  };
315
2979
 
316
2980
  type JSXRemoveAttributesPlugin = {
@@ -325,19 +2989,6 @@ interface LicenseOptions {
325
2989
  path?: string;
326
2990
  }
327
2991
 
328
- type InternalOXCTransformPluginConfig = TransformOptions$1 & {
329
- exclude?: FilterPattern;
330
- include?: FilterPattern;
331
- };
332
- type OXCTransformPluginConfig = Omit<TransformOptions$1, "cwd" | "sourcemap" | "target" | "typescript"> & {
333
- exclude?: FilterPattern;
334
- include?: FilterPattern;
335
- jsx?: Omit<JsxOptions, "refresh"> | "preserve";
336
- };
337
- type OxcResolveOptions = Omit<NapiResolveOptions, "tsconfig"> & {
338
- ignoreSideEffectsForRoot?: boolean;
339
- };
340
-
341
2992
  interface RawLoaderOptions {
342
2993
  exclude?: FilterPattern;
343
2994
  include?: FilterPattern;
@@ -353,6 +3004,49 @@ interface SourcemapsPluginOptions {
353
3004
  include?: FilterPattern;
354
3005
  }
355
3006
 
3007
+ interface UrlOptions {
3008
+ destDir?: string;
3009
+ emitFiles: boolean;
3010
+ exclude?: FilterPattern;
3011
+ fileName: string;
3012
+ include?: FilterPattern;
3013
+ limit: number;
3014
+ publicPath?: string;
3015
+ sourceDir?: string;
3016
+ }
3017
+
3018
+ type MarkOptional<Type, Keys extends keyof Type> = Type extends Type ? Omit<Type, Keys> & Partial<Pick<Type, Keys>> : never;
3019
+ type EsbuildPluginConfig = Options$1 & {
3020
+ logger: PailServerType;
3021
+ };
3022
+ type OptimizeDepsOptions = {
3023
+ cwd: string;
3024
+ esbuildOptions?: BuildOptions;
3025
+ exclude?: string[];
3026
+ include: string[];
3027
+ sourceMap: boolean;
3028
+ };
3029
+ type Options$1 = Omit<TransformOptions$1, "loader" | "sourcemap"> & {
3030
+ exclude?: FilterPattern;
3031
+ include?: FilterPattern;
3032
+ loaders?: Record<string, Loader | false>;
3033
+ optimizeDeps?: MarkOptional<OptimizeDepsOptions, "cwd" | "sourceMap">;
3034
+ sourceMap?: boolean;
3035
+ };
3036
+
3037
+ type InternalOXCTransformPluginConfig = TransformOptions$2 & {
3038
+ exclude?: FilterPattern;
3039
+ include?: FilterPattern;
3040
+ };
3041
+ type OXCTransformPluginConfig = Omit<TransformOptions$2, "cwd" | "sourcemap" | "target" | "typescript"> & {
3042
+ exclude?: FilterPattern;
3043
+ include?: FilterPattern;
3044
+ jsx?: Omit<JsxOptions, "refresh"> | "preserve";
3045
+ };
3046
+ type OxcResolveOptions = Omit<NapiResolveOptions, "tsconfig"> & {
3047
+ ignoreSideEffectsForRoot?: boolean;
3048
+ };
3049
+
356
3050
  interface SucrasePluginConfig extends Options$3 {
357
3051
  exclude?: FilterPattern;
358
3052
  include?: FilterPattern;
@@ -840,7 +3534,7 @@ interface Options extends Config {
840
3534
  */
841
3535
  sourceRoot?: string;
842
3536
  plugin?: Plugin;
843
- isModule?: boolean | "unknown";
3537
+ isModule?: boolean | "unknown" | "commonjs";
844
3538
  /**
845
3539
  * Destination path. Note that this value is used only to fix source path
846
3540
  * of source map files and swc does not write output to this path.
@@ -1083,7 +3777,7 @@ interface EsParserConfig {
1083
3777
  */
1084
3778
  importAssertions?: boolean;
1085
3779
  /**
1086
- * Defaults to `false`
3780
+ * @deprecated Always true in swc
1087
3781
  */
1088
3782
  importAttributes?: boolean;
1089
3783
  /**
@@ -1137,6 +3831,7 @@ interface TransformConfig {
1137
3831
  * https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax
1138
3832
  */
1139
3833
  verbatimModuleSyntax?: boolean;
3834
+ tsEnumIsMutable?: boolean;
1140
3835
  }
1141
3836
  interface ReactConfig {
1142
3837
  /**
@@ -2464,21 +5159,17 @@ type PatchTypesOptions = {
2464
5159
  identifierReplacements?: Record<string, Record<string, string>>;
2465
5160
  };
2466
5161
 
5162
+ declare global {
5163
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5164
+ interface SymbolConstructor {
5165
+ readonly observable: symbol;
5166
+ }
5167
+ }
5168
+
2467
5169
  type TsconfigPathsPluginOptions = {
2468
5170
  resolveAbsolutePath?: boolean;
2469
5171
  };
2470
5172
 
2471
- interface UrlOptions {
2472
- destDir?: string;
2473
- emitFiles: boolean;
2474
- exclude?: FilterPattern;
2475
- fileName: string;
2476
- include?: FilterPattern;
2477
- limit: number;
2478
- publicPath?: string;
2479
- sourceDir?: string;
2480
- }
2481
-
2482
5173
  interface RollupDynamicImportVariablesOptions {
2483
5174
  errorWhenNoFilesFound?: boolean;
2484
5175
  exclude?: FilterPattern;
@@ -2496,6 +5187,8 @@ interface PackemRollupOptions {
2496
5187
  cjsInterop?: CJSInteropOptions;
2497
5188
  commonjs: RollupCommonJSOptions | false;
2498
5189
  copy?: CopyPluginOptions | false;
5190
+ dataUri?: DataUriPluginOptions | false;
5191
+ debarrel?: DebarrelPluginOptions | false;
2499
5192
  dts: Options$2;
2500
5193
  dynamicVars?: RollupDynamicImportVariablesOptions | false;
2501
5194
  esbuild?: Options$1 | false;
@@ -2544,11 +5237,5 @@ type TransformerFn = ((config: EsbuildPluginConfig | InternalOXCTransformPluginC
2544
5237
  };
2545
5238
  type TransformerName = "esbuild" | "oxc" | "sucrase" | "swc";
2546
5239
 
2547
- type IsolatedDeclarationsOptions = {
2548
- exclude?: FilterPattern;
2549
- ignoreErrors?: boolean;
2550
- include?: FilterPattern;
2551
- };
2552
-
2553
5240
  export { sucrasePlugin as s };
2554
- export type { EsbuildPluginConfig as E, IsolatedDeclarationsTransformer as I, PackemRollupOptions as P, SwcPluginConfig as S, TransformerFn as T, TransformerName as a, IsolatedDeclarationsResult as b, InternalOXCTransformPluginConfig as c, SucrasePluginConfig as d };
5241
+ export type { BuildContext as B, Environment as E, Format as F, IsolatedDeclarationsTransformer as I, Mode as M, PackemRollupOptions as P, Runtime as R, SwcPluginConfig as S, TransformerFn as T, TransformerName as a, BuildContextBuildAssetAndChunk as b, BuildContextBuildEntry as c, BuildHooks as d, EsbuildPluginConfig as e, IsolatedDeclarationsResult as f, InternalOXCTransformPluginConfig as g, SucrasePluginConfig as h };