Skip to main content

tsz_cli/
args.rs

1use clap::{Parser, ValueEnum};
2use std::path::PathBuf;
3
4use crate::config::ModuleResolutionKind;
5use tsz::emitter::{ModuleKind, ScriptTarget};
6
7/// CLI arguments for the tsz binary.
8#[derive(Parser, Debug)]
9#[command(
10    name = "tsz",
11    version,
12    about = "Codename Zang (Persian for rust) - TypeScript in Rust"
13)]
14pub struct CliArgs {
15    // ==================== Command-line Only Options ====================
16    /// Show all compiler options.
17    #[arg(long)]
18    pub all: bool,
19
20    /// Build one or more projects and their dependencies, if out of date.
21    #[arg(short = 'b', long)]
22    pub build: bool,
23
24    /// Initializes a TypeScript project and creates a tsconfig.json file.
25    #[arg(long)]
26    pub init: bool,
27
28    /// Print names of files that are part of the compilation and then stop processing.
29    #[arg(long = "listFilesOnly", alias = "list-files-only")]
30    pub list_files_only: bool,
31
32    /// Set the language of the messaging from TypeScript.
33    #[arg(long)]
34    pub locale: Option<String>,
35
36    /// Print the final configuration instead of building.
37    #[arg(long = "showConfig", alias = "show-config")]
38    pub show_config: bool,
39
40    /// Watch input files and recompile on changes.
41    #[arg(short = 'w', long)]
42    pub watch: bool,
43
44    /// Path to tsconfig.json or a directory containing it.
45    #[arg(short = 'p', long = "project")]
46    pub project: Option<PathBuf>,
47
48    // ==================== Language and Environment ====================
49    /// Set the JavaScript language version for emitted JavaScript.
50    #[arg(short = 't', long, value_enum, ignore_case = true)]
51    pub target: Option<Target>,
52
53    /// Specify what module code is generated.
54    #[arg(short = 'm', long, value_enum, ignore_case = true)]
55    pub module: Option<Module>,
56
57    /// Specify a set of bundled library declaration files.
58    #[arg(long, value_delimiter = ',')]
59    pub lib: Option<Vec<String>>,
60
61    /// Specify what JSX code is generated.
62    #[arg(long, value_enum)]
63    pub jsx: Option<JsxEmit>,
64
65    /// Specify the JSX factory function (e.g. 'React.createElement').
66    #[arg(long = "jsxFactory", alias = "jsx-factory")]
67    pub jsx_factory: Option<String>,
68
69    /// Specify the JSX Fragment reference (e.g. 'React.Fragment').
70    #[arg(long = "jsxFragmentFactory", alias = "jsx-fragment-factory")]
71    pub jsx_fragment_factory: Option<String>,
72
73    /// Specify module specifier for JSX factory functions (e.g. 'react').
74    #[arg(long = "jsxImportSource", alias = "jsx-import-source")]
75    pub jsx_import_source: Option<String>,
76
77    /// Disable including any library files, including the default lib.d.ts.
78    #[arg(long = "noLib", alias = "no-lib")]
79    pub no_lib: bool,
80
81    /// Emit ECMAScript-standard-compliant class fields.
82    #[arg(
83        long = "useDefineForClassFields",
84        alias = "use-define-for-class-fields"
85    )]
86    pub use_define_for_class_fields: Option<bool>,
87
88    /// Control what method is used to detect module-format JS files.
89    #[arg(long = "moduleDetection", alias = "module-detection", value_enum)]
90    pub module_detection: Option<ModuleDetection>,
91
92    /// Enable experimental support for legacy experimental decorators.
93    #[arg(long = "experimentalDecorators", alias = "experimental-decorators")]
94    pub experimental_decorators: bool,
95
96    /// Emit design-type metadata for decorated declarations in source files.
97    #[arg(long = "emitDecoratorMetadata", alias = "emit-decorator-metadata")]
98    pub emit_decorator_metadata: bool,
99
100    // ==================== Modules ====================
101    /// Specify how TypeScript looks up a file from a given module specifier.
102    #[arg(long = "moduleResolution", alias = "module-resolution", value_enum)]
103    pub module_resolution: Option<ModuleResolution>,
104
105    /// Specify the base directory to resolve non-relative module names.
106    #[arg(long = "baseUrl", alias = "base-url")]
107    pub base_url: Option<PathBuf>,
108
109    /// Specify multiple folders that act like './`node_modules/@types`'.
110    #[arg(long = "typeRoots", alias = "type-roots", value_delimiter = ',')]
111    pub type_roots: Option<Vec<PathBuf>>,
112
113    /// Specify type package names to be included without being referenced in a source file.
114    #[arg(long, value_delimiter = ',')]
115    pub types: Option<Vec<String>>,
116
117    /// Allow multiple folders to be treated as one when resolving modules.
118    #[arg(long = "rootDirs", alias = "root-dirs", value_delimiter = ',')]
119    pub root_dirs: Option<Vec<PathBuf>>,
120
121    /// Specify a set of entries that re-map imports to additional lookup locations.
122    /// Accepted for CLI compatibility; normally set in tsconfig.json.
123    #[arg(long, value_delimiter = ',', hide = true)]
124    pub paths: Option<Vec<String>>,
125
126    /// Specify list of language service plugins.
127    /// Accepted for CLI compatibility; normally set in tsconfig.json.
128    #[arg(long, value_delimiter = ',', hide = true)]
129    pub plugins: Option<Vec<String>>,
130
131    /// Enable importing .json files.
132    #[arg(long = "resolveJsonModule", alias = "resolve-json-module")]
133    pub resolve_json_module: bool,
134
135    /// Use the package.json 'exports' field when resolving package imports.
136    #[arg(
137        long = "resolvePackageJsonExports",
138        alias = "resolve-package-json-exports"
139    )]
140    pub resolve_package_json_exports: Option<bool>,
141
142    /// Use the package.json 'imports' field when resolving imports.
143    #[arg(
144        long = "resolvePackageJsonImports",
145        alias = "resolve-package-json-imports"
146    )]
147    pub resolve_package_json_imports: Option<bool>,
148
149    /// List of file name suffixes to search when resolving a module.
150    #[arg(
151        long = "moduleSuffixes",
152        alias = "module-suffixes",
153        value_delimiter = ','
154    )]
155    pub module_suffixes: Option<Vec<String>>,
156
157    /// Enable importing files with any extension, provided a declaration file is present.
158    #[arg(
159        long = "allowArbitraryExtensions",
160        alias = "allow-arbitrary-extensions"
161    )]
162    pub allow_arbitrary_extensions: bool,
163
164    /// Allow imports to include TypeScript file extensions.
165    #[arg(
166        long = "allowImportingTsExtensions",
167        alias = "allow-importing-ts-extensions"
168    )]
169    pub allow_importing_ts_extensions: bool,
170
171    /// Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths.
172    #[arg(
173        long = "rewriteRelativeImportExtensions",
174        alias = "rewrite-relative-import-extensions"
175    )]
176    pub rewrite_relative_import_extensions: bool,
177
178    /// Conditions to set in addition to the resolver-specific defaults when resolving imports.
179    #[arg(
180        long = "customConditions",
181        alias = "custom-conditions",
182        value_delimiter = ','
183    )]
184    pub custom_conditions: Option<Vec<String>>,
185
186    /// Disallow 'import's, 'require's or '<reference>'s from expanding the number of files.
187    #[arg(long = "noResolve", alias = "no-resolve")]
188    pub no_resolve: bool,
189
190    /// Allow accessing UMD globals from modules.
191    #[arg(long = "allowUmdGlobalAccess", alias = "allow-umd-global-access")]
192    pub allow_umd_global_access: bool,
193
194    /// Check side effect imports.
195    #[arg(
196        long = "noUncheckedSideEffectImports",
197        alias = "no-unchecked-side-effect-imports"
198    )]
199    pub no_unchecked_side_effect_imports: bool,
200
201    // ==================== JavaScript Support ====================
202    /// Allow JavaScript files to be a part of your program.
203    #[arg(long = "allowJs", alias = "allow-js")]
204    pub allow_js: bool,
205
206    /// Enable error reporting in type-checked JavaScript files.
207    #[arg(long = "checkJs", alias = "check-js")]
208    pub check_js: bool,
209
210    /// Specify the maximum folder depth used for checking JavaScript files from '`node_modules`'.
211    #[arg(long = "maxNodeModuleJsDepth", alias = "max-node-module-js-depth")]
212    pub max_node_module_js_depth: Option<u32>,
213
214    // ==================== Emit ====================
215    /// Generate .d.ts files from TypeScript and JavaScript files in your project.
216    #[arg(long = "declaration", short = 'd')]
217    pub declaration: bool,
218
219    /// Specify the output directory for generated declaration files.
220    #[arg(long = "declarationDir", alias = "declaration-dir")]
221    pub declaration_dir: Option<PathBuf>,
222
223    /// Create sourcemaps for d.ts files.
224    #[arg(long = "declarationMap", alias = "declaration-map")]
225    pub declaration_map: bool,
226
227    /// Only output d.ts files and not JavaScript files.
228    #[arg(long = "emitDeclarationOnly", alias = "emit-declaration-only")]
229    pub emit_declaration_only: bool,
230
231    /// Create source map files for emitted JavaScript files.
232    #[arg(long = "sourceMap", alias = "source-map")]
233    pub source_map: bool,
234
235    /// Include sourcemap files inside the emitted JavaScript.
236    #[arg(long = "inlineSourceMap", alias = "inline-source-map")]
237    pub inline_source_map: bool,
238
239    /// Include source code in the sourcemaps inside the emitted JavaScript.
240    #[arg(long = "inlineSources", alias = "inline-sources")]
241    pub inline_sources: bool,
242
243    /// Specify an output folder for all emitted files.
244    #[arg(long = "outDir", alias = "out-dir")]
245    pub out_dir: Option<PathBuf>,
246
247    /// Specify the root folder within your source files.
248    #[arg(long = "rootDir", alias = "root-dir")]
249    pub root_dir: Option<PathBuf>,
250
251    /// Specify a file that bundles all outputs into one JavaScript file.
252    #[arg(long = "outFile", alias = "out-file")]
253    pub out_file: Option<PathBuf>,
254
255    /// Disable emitting files from a compilation.
256    #[arg(long = "noEmit", alias = "no-emit")]
257    pub no_emit: bool,
258
259    /// Disable emitting files if any type checking errors are reported.
260    #[arg(long = "noEmitOnError", alias = "no-emit-on-error")]
261    pub no_emit_on_error: bool,
262
263    /// Disable generating custom helper functions like '__extends' in compiled output.
264    #[arg(long = "noEmitHelpers", alias = "no-emit-helpers")]
265    pub no_emit_helpers: bool,
266
267    /// Allow importing helper functions from tslib once per project.
268    #[arg(long = "importHelpers", alias = "import-helpers")]
269    pub import_helpers: bool,
270
271    /// Emit more compliant, but verbose and less performant JavaScript for iteration.
272    #[arg(long = "downlevelIteration", alias = "downlevel-iteration")]
273    pub downlevel_iteration: bool,
274
275    /// Specify the location where debugger should locate map files instead of generated locations.
276    #[arg(long = "mapRoot", alias = "map-root")]
277    pub map_root: Option<String>,
278
279    /// Specify the root path for debuggers to find the reference source code.
280    #[arg(long = "sourceRoot", alias = "source-root")]
281    pub source_root: Option<String>,
282
283    /// Set the newline character for emitting files.
284    #[arg(long = "newLine", alias = "new-line", value_enum)]
285    pub new_line: Option<NewLine>,
286
287    /// Disable emitting comments.
288    #[arg(long = "removeComments", alias = "remove-comments")]
289    pub remove_comments: bool,
290
291    /// Disable erasing 'const enum' declarations in generated code.
292    #[arg(long = "preserveConstEnums", alias = "preserve-const-enums")]
293    pub preserve_const_enums: bool,
294
295    /// Disable emitting declarations that have '@internal' in their `JSDoc` comments.
296    #[arg(long = "stripInternal", alias = "strip-internal")]
297    pub strip_internal: bool,
298
299    /// Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
300    #[arg(long = "emitBOM", alias = "emit-bom")]
301    pub emit_bom: bool,
302
303    // ==================== Interop Constraints ====================
304    /// Emit additional JavaScript to ease support for importing `CommonJS` modules.
305    #[arg(long = "esModuleInterop", alias = "es-module-interop")]
306    pub es_module_interop: bool,
307
308    /// Allow 'import x from y' when a module doesn't have a default export.
309    #[arg(
310        long = "allowSyntheticDefaultImports",
311        alias = "allow-synthetic-default-imports"
312    )]
313    pub allow_synthetic_default_imports: Option<bool>,
314
315    /// Ensure that each file can be safely transpiled without relying on other imports.
316    #[arg(long = "isolatedModules", alias = "isolated-modules")]
317    pub isolated_modules: bool,
318
319    /// Require sufficient annotation on exports so other tools can trivially generate declaration files.
320    #[arg(long = "isolatedDeclarations", alias = "isolated-declarations")]
321    pub isolated_declarations: bool,
322
323    /// Do not transform or elide any imports or exports not marked as type-only.
324    #[arg(long = "verbatimModuleSyntax", alias = "verbatim-module-syntax")]
325    pub verbatim_module_syntax: bool,
326
327    /// Ensure that casing is correct in imports.
328    #[arg(
329        long = "forceConsistentCasingInFileNames",
330        alias = "force-consistent-casing-in-file-names"
331    )]
332    pub force_consistent_casing_in_file_names: Option<bool>,
333
334    /// Disable resolving symlinks to their realpath.
335    #[arg(long = "preserveSymlinks", alias = "preserve-symlinks")]
336    pub preserve_symlinks: bool,
337
338    /// Do not allow runtime constructs that are not part of ECMAScript.
339    #[arg(long = "erasableSyntaxOnly", alias = "erasable-syntax-only")]
340    pub erasable_syntax_only: bool,
341
342    // ==================== Type Checking ====================
343    /// Enable all strict type-checking options.
344    #[arg(long)]
345    pub strict: bool,
346
347    /// Enable error reporting for expressions and declarations with an implied 'any' type.
348    #[arg(long = "noImplicitAny", alias = "no-implicit-any")]
349    pub no_implicit_any: Option<bool>,
350
351    /// When type checking, take into account 'null' and 'undefined'.
352    #[arg(long = "strictNullChecks", alias = "strict-null-checks")]
353    pub strict_null_checks: Option<bool>,
354
355    /// When assigning functions, check to ensure parameters and the return values are subtype-compatible.
356    #[arg(long = "strictFunctionTypes", alias = "strict-function-types")]
357    pub strict_function_types: Option<bool>,
358
359    /// Check that the arguments for 'bind', 'call', and 'apply' methods match the original function.
360    #[arg(long = "strictBindCallApply", alias = "strict-bind-call-apply")]
361    pub strict_bind_call_apply: Option<bool>,
362
363    /// Check for class properties that are declared but not set in the constructor.
364    #[arg(
365        long = "strictPropertyInitialization",
366        alias = "strict-property-initialization"
367    )]
368    pub strict_property_initialization: Option<bool>,
369
370    /// Built-in iterators are instantiated with a '`TReturn`' type of 'undefined' instead of 'any'.
371    #[arg(
372        long = "strictBuiltinIteratorReturn",
373        alias = "strict-builtin-iterator-return"
374    )]
375    pub strict_builtin_iterator_return: Option<bool>,
376
377    /// Enable error reporting when 'this' is given the type 'any'.
378    #[arg(long = "noImplicitThis", alias = "no-implicit-this")]
379    pub no_implicit_this: Option<bool>,
380
381    /// Default catch clause variables as 'unknown' instead of 'any'.
382    #[arg(
383        long = "useUnknownInCatchVariables",
384        alias = "use-unknown-in-catch-variables"
385    )]
386    pub use_unknown_in_catch_variables: Option<bool>,
387
388    /// Ensure 'use strict' is always emitted.
389    #[arg(long = "alwaysStrict", alias = "always-strict")]
390    pub always_strict: Option<bool>,
391
392    /// Enable error reporting when local variables aren't read.
393    #[arg(long = "noUnusedLocals", alias = "no-unused-locals")]
394    pub no_unused_locals: bool,
395
396    /// Raise an error when a function parameter isn't read.
397    #[arg(long = "noUnusedParameters", alias = "no-unused-parameters")]
398    pub no_unused_parameters: bool,
399
400    /// Interpret optional property types as written, rather than adding 'undefined'.
401    #[arg(
402        long = "exactOptionalPropertyTypes",
403        alias = "exact-optional-property-types"
404    )]
405    pub exact_optional_property_types: bool,
406
407    /// Enable error reporting for codepaths that do not explicitly return in a function.
408    #[arg(long = "noImplicitReturns", alias = "no-implicit-returns")]
409    pub no_implicit_returns: bool,
410
411    /// Enable error reporting for fallthrough cases in switch statements.
412    #[arg(
413        long = "noFallthroughCasesInSwitch",
414        alias = "no-fallthrough-cases-in-switch"
415    )]
416    pub no_fallthrough_cases_in_switch: bool,
417
418    /// Enable Sound Mode for stricter type checking beyond TypeScript's defaults.
419    /// Catches common unsoundness like mutable array covariance, method bivariance,
420    /// `any` escapes, and excess properties via sticky freshness.
421    /// Uses `TS9xxx` diagnostic codes (TS9001-TS9008).
422    #[arg(long)]
423    pub sound: bool,
424
425    /// Add 'undefined' to a type when accessed using an index.
426    #[arg(
427        long = "noUncheckedIndexedAccess",
428        alias = "no-unchecked-indexed-access"
429    )]
430    pub no_unchecked_indexed_access: bool,
431
432    /// Ensure overriding members in derived classes are marked with an override modifier.
433    #[arg(long = "noImplicitOverride", alias = "no-implicit-override")]
434    pub no_implicit_override: bool,
435
436    /// Enforces using indexed accessors for keys declared using an indexed type.
437    #[arg(
438        long = "noPropertyAccessFromIndexSignature",
439        alias = "no-property-access-from-index-signature"
440    )]
441    pub no_property_access_from_index_signature: bool,
442
443    /// Disable error reporting for unreachable code.
444    #[arg(long = "allowUnreachableCode", alias = "allow-unreachable-code")]
445    pub allow_unreachable_code: Option<bool>,
446
447    /// Disable error reporting for unused labels.
448    #[arg(long = "allowUnusedLabels", alias = "allow-unused-labels")]
449    pub allow_unused_labels: Option<bool>,
450
451    // ==================== Completeness ====================
452    /// Skip type checking .d.ts files that are included with TypeScript.
453    #[arg(long = "skipDefaultLibCheck", alias = "skip-default-lib-check")]
454    pub skip_default_lib_check: bool,
455
456    /// Skip type checking all .d.ts files.
457    #[arg(long = "skipLibCheck", alias = "skip-lib-check")]
458    pub skip_lib_check: bool,
459
460    // ==================== Projects ====================
461    /// Enable constraints that allow a TypeScript project to be used with project references.
462    #[arg(long)]
463    pub composite: bool,
464
465    /// Save .tsbuildinfo files to allow for incremental compilation of projects.
466    #[arg(short = 'i', long)]
467    pub incremental: bool,
468
469    /// Specify the path to .tsbuildinfo incremental compilation file.
470    #[arg(long = "tsBuildInfoFile", alias = "ts-build-info-file")]
471    pub ts_build_info_file: Option<PathBuf>,
472
473    /// Reduce the number of projects loaded automatically by TypeScript.
474    #[arg(
475        long = "disableReferencedProjectLoad",
476        alias = "disable-referenced-project-load"
477    )]
478    pub disable_referenced_project_load: bool,
479
480    /// Opt a project out of multi-project reference checking when editing.
481    #[arg(
482        long = "disableSolutionSearching",
483        alias = "disable-solution-searching"
484    )]
485    pub disable_solution_searching: bool,
486
487    /// Disable preferring source files instead of declaration files when referencing composite projects.
488    #[arg(
489        long = "disableSourceOfProjectReferenceRedirect",
490        alias = "disable-source-of-project-reference-redirect"
491    )]
492    pub disable_source_of_project_reference_redirect: bool,
493
494    // ==================== Compiler Diagnostics ====================
495    /// Output compiler performance information after building.
496    #[arg(long)]
497    pub diagnostics: bool,
498
499    /// Output more detailed compiler performance information after building.
500    #[arg(long = "extendedDiagnostics", alias = "extended-diagnostics")]
501    pub extended_diagnostics: bool,
502
503    /// Print files read during the compilation including why it was included.
504    #[arg(long = "explainFiles", alias = "explain-files")]
505    pub explain_files: bool,
506
507    /// Print all of the files read during the compilation.
508    #[arg(long = "listFiles", alias = "list-files")]
509    pub list_files: bool,
510
511    /// Print the names of emitted files after a compilation.
512    #[arg(long = "listEmittedFiles", alias = "list-emitted-files")]
513    pub list_emitted_files: bool,
514
515    /// Log paths used during the 'moduleResolution' process.
516    #[arg(long = "traceResolution", alias = "trace-resolution")]
517    pub trace_resolution: bool,
518
519    /// Log all dependencies that were resolved during compilation.
520    #[arg(long = "traceDependencies", alias = "trace-dependencies")]
521    pub trace_dependencies: bool,
522
523    /// Generates an event trace and a list of types.
524    #[arg(long = "generateTrace", alias = "generate-trace")]
525    pub generate_trace: Option<PathBuf>,
526
527    /// Emit a v8 CPU profile of the compiler run for debugging.
528    #[arg(long = "generateCpuProfile", alias = "generate-cpu-profile")]
529    pub generate_cpu_profile: Option<PathBuf>,
530
531    /// Disable full type checking (only critical parse and emit errors will be reported).
532    #[arg(long = "noCheck", alias = "no-check")]
533    pub no_check: bool,
534
535    // ==================== Output Formatting ====================
536    /// Enable color and formatting in TypeScript's output to make compiler errors easier to read.
537    #[arg(long)]
538    pub pretty: Option<bool>,
539
540    /// Disable truncating types in error messages.
541    #[arg(long = "noErrorTruncation", alias = "no-error-truncation")]
542    pub no_error_truncation: bool,
543
544    /// Disable wiping the console in watch mode.
545    #[arg(long = "preserveWatchOutput", alias = "preserve-watch-output")]
546    pub preserve_watch_output: bool,
547
548    // ==================== Watch Mode Options ====================
549    /// Specify how the TypeScript watch mode works.
550    #[arg(long = "watchFile", alias = "watch-file", value_enum)]
551    pub watch_file: Option<WatchFileKind>,
552
553    /// Specify how directories are watched on systems that lack recursive file-watching functionality.
554    #[arg(long = "watchDirectory", alias = "watch-directory", value_enum)]
555    pub watch_directory: Option<WatchDirectoryKind>,
556
557    /// Specify what approach the watcher should use if the system runs out of native file watchers.
558    #[arg(long = "fallbackPolling", alias = "fallback-polling", value_enum)]
559    pub fallback_polling: Option<PollingWatchKind>,
560
561    /// Synchronously call callbacks and update the state of directory watchers.
562    #[arg(
563        long = "synchronousWatchDirectory",
564        alias = "synchronous-watch-directory"
565    )]
566    pub synchronous_watch_directory: bool,
567
568    /// Remove a list of directories from the watch process.
569    #[arg(
570        long = "excludeDirectories",
571        alias = "exclude-directories",
572        value_delimiter = ','
573    )]
574    pub exclude_directories: Option<Vec<PathBuf>>,
575
576    /// Remove a list of files from the watch mode's processing.
577    #[arg(long = "excludeFiles", alias = "exclude-files", value_delimiter = ',')]
578    pub exclude_files: Option<Vec<PathBuf>>,
579
580    // ==================== Build Mode Options ====================
581    /// Enable verbose logging (build mode).
582    #[arg(long, visible_alias = "verbose")]
583    pub build_verbose: bool,
584
585    /// Show what would be built (or deleted, if specified with '--clean').
586    #[arg(long)]
587    pub dry: bool,
588
589    /// Build all projects, including those that appear to be up to date.
590    #[arg(short = 'f', long)]
591    pub force: bool,
592
593    /// Delete the outputs of all projects.
594    #[arg(long)]
595    pub clean: bool,
596
597    /// Skip building downstream projects on error in upstream project.
598    #[arg(long = "stopBuildOnErrors", alias = "stop-build-on-errors")]
599    pub stop_build_on_errors: bool,
600
601    // ==================== Watch and Build Modes ====================
602    /// Have recompiles in projects that use 'incremental' and 'watch' mode assume changes only affect direct dependencies.
603    #[arg(
604        long = "assumeChangesOnlyAffectDirectDependencies",
605        alias = "assume-changes-only-affect-direct-dependencies"
606    )]
607    pub assume_changes_only_affect_direct_dependencies: bool,
608
609    // ==================== Backwards Compatibility ====================
610    /// Deprecated: Specify the object invoked for 'createElement' (use --jsxFactory instead).
611    #[arg(long = "reactNamespace", alias = "react-namespace", hide = true)]
612    pub react_namespace: Option<String>,
613
614    /// Deprecated: In early versions, manually set the text encoding for reading files.
615    #[arg(long, hide = true)]
616    pub charset: Option<String>,
617
618    /// Deprecated: Specify emit/checking behavior for imports that are only used for types.
619    #[arg(
620        long = "importsNotUsedAsValues",
621        alias = "imports-not-used-as-values",
622        value_enum,
623        hide = true
624    )]
625    pub imports_not_used_as_values: Option<ImportsNotUsedAsValues>,
626
627    /// Deprecated: Make keyof only return strings instead of string, numbers or symbols.
628    #[arg(long = "keyofStringsOnly", alias = "keyof-strings-only", hide = true)]
629    pub keyof_strings_only: bool,
630
631    /// Deprecated: Disable adding 'use strict' directives in emitted JavaScript files.
632    #[arg(
633        long = "noImplicitUseStrict",
634        alias = "no-implicit-use-strict",
635        hide = true
636    )]
637    pub no_implicit_use_strict: bool,
638
639    /// Deprecated: Disable strict checking of generic signatures in function types.
640    #[arg(
641        long = "noStrictGenericChecks",
642        alias = "no-strict-generic-checks",
643        hide = true
644    )]
645    pub no_strict_generic_checks: bool,
646
647    /// Deprecated: Use 'outFile' instead.
648    #[arg(long, hide = true)]
649    pub out: Option<PathBuf>,
650
651    /// Deprecated: Preserve unused imported values in the JavaScript output.
652    #[arg(
653        long = "preserveValueImports",
654        alias = "preserve-value-imports",
655        hide = true
656    )]
657    pub preserve_value_imports: bool,
658
659    /// Deprecated: Disable reporting of excess property errors during the creation of object literals.
660    #[arg(
661        long = "suppressExcessPropertyErrors",
662        alias = "suppress-excess-property-errors",
663        hide = true
664    )]
665    pub suppress_excess_property_errors: bool,
666
667    /// Deprecated: Suppress 'noImplicitAny' errors when indexing objects that lack index signatures.
668    #[arg(
669        long = "suppressImplicitAnyIndexErrors",
670        alias = "suppress-implicit-any-index-errors",
671        hide = true
672    )]
673    pub suppress_implicit_any_index_errors: bool,
674
675    // ==================== Editor Support ====================
676    /// Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.
677    #[arg(long = "disableSizeLimit", alias = "disable-size-limit")]
678    pub disable_size_limit: bool,
679
680    // ==================== Custom Options ====================
681    /// Override the compiler version used for typesVersions resolution
682    /// (or set `TSZ_TYPES_VERSIONS_COMPILER_VERSION`).
683    #[arg(
684        long = "typesVersions",
685        alias = "types-versions",
686        value_name = "VERSION"
687    )]
688    pub types_versions_compiler_version: Option<String>,
689
690    // ==================== Batch Mode ====================
691    /// Enter batch mode: read project paths from stdin, one per line,
692    /// compile each, and print diagnostics followed by a sentinel line.
693    /// Used by the conformance runner's process pool for amortized startup.
694    #[arg(long, hide = true)]
695    pub batch: bool,
696
697    // ==================== Input Files ====================
698    /// Input files to compile.
699    #[arg(value_name = "FILE")]
700    pub files: Vec<PathBuf>,
701}
702
703#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
704pub enum Target {
705    Es3,
706    Es5,
707    #[value(alias = "es6")]
708    Es2015,
709    Es2016,
710    Es2017,
711    Es2018,
712    Es2019,
713    Es2020,
714    Es2021,
715    Es2022,
716    Es2023,
717    Es2024,
718    Es2025,
719    #[value(name = "esnext", alias = "es-next")]
720    EsNext,
721}
722
723impl Target {
724    pub const fn to_script_target(self) -> ScriptTarget {
725        match self {
726            Self::Es3 => ScriptTarget::ES3,
727            Self::Es5 => ScriptTarget::ES5,
728            Self::Es2015 => ScriptTarget::ES2015,
729            Self::Es2016 => ScriptTarget::ES2016,
730            Self::Es2017 => ScriptTarget::ES2017,
731            Self::Es2018 => ScriptTarget::ES2018,
732            Self::Es2019 => ScriptTarget::ES2019,
733            Self::Es2020 => ScriptTarget::ES2020,
734            Self::Es2021 => ScriptTarget::ES2021,
735            Self::Es2022 => ScriptTarget::ES2022,
736            Self::Es2023 => ScriptTarget::ES2023,
737            Self::Es2024 => ScriptTarget::ES2024,
738            Self::Es2025 => ScriptTarget::ES2025,
739            Self::EsNext => ScriptTarget::ESNext,
740        }
741    }
742}
743
744#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
745pub enum Module {
746    None,
747    #[value(name = "commonjs", alias = "common-js")]
748    CommonJs,
749    Amd,
750    Umd,
751    System,
752    #[value(alias = "es6")]
753    Es2015,
754    Es2020,
755    Es2022,
756    #[value(name = "esnext", alias = "es-next")]
757    EsNext,
758    #[value(name = "node16", alias = "node-16")]
759    Node16,
760    #[value(name = "node18", alias = "node-18")]
761    Node18,
762    #[value(name = "node20", alias = "node-20")]
763    Node20,
764    #[value(name = "nodenext", alias = "node-next")]
765    NodeNext,
766    /// Preserve the original module syntax.
767    Preserve,
768}
769
770impl Module {
771    pub const fn to_module_kind(self) -> ModuleKind {
772        match self {
773            Self::None => ModuleKind::None,
774            Self::CommonJs => ModuleKind::CommonJS,
775            Self::Amd => ModuleKind::AMD,
776            Self::Umd => ModuleKind::UMD,
777            Self::System => ModuleKind::System,
778            Self::Es2015 => ModuleKind::ES2015,
779            Self::Es2020 => ModuleKind::ES2020,
780            Self::Es2022 => ModuleKind::ES2022,
781            Self::EsNext => ModuleKind::ESNext,
782            Self::Preserve => ModuleKind::Preserve,
783            Self::Node16 | Self::Node18 | Self::Node20 => ModuleKind::Node16,
784            Self::NodeNext => ModuleKind::NodeNext,
785        }
786    }
787}
788
789#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
790pub enum JsxEmit {
791    /// Keep the JSX as part of the output to be further transformed by another transform step.
792    Preserve,
793    /// Emit .js files with JSX changed to the equivalent React.createElement calls.
794    React,
795    /// Emit .js files with the JSX changed to _jsx calls.
796    #[value(name = "react-jsx")]
797    ReactJsx,
798    /// Emit .js files with the JSX changed to _jsx calls (development mode).
799    #[value(name = "react-jsxdev")]
800    ReactJsxDev,
801    /// Keep the JSX as part of the output (like preserve), but also emit .js files.
802    #[value(name = "react-native")]
803    ReactNative,
804}
805
806#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
807pub enum ModuleResolution {
808    /// Deprecated: TypeScript 1.6 resolution strategy.
809    Classic,
810    /// Node.js style resolution for `CommonJS`.
811    #[value(alias = "node")]
812    Node10,
813    /// Node.js 16+ resolution for ES modules and `CommonJS`.
814    Node16,
815    /// Latest Node.js resolution for ES modules and `CommonJS`.
816    #[value(name = "nodenext", alias = "node-next")]
817    NodeNext,
818    /// Resolution for bundlers (Webpack, Rollup, esbuild, etc).
819    Bundler,
820}
821
822impl ModuleResolution {
823    pub const fn to_module_resolution_kind(self) -> ModuleResolutionKind {
824        match self {
825            Self::Classic => ModuleResolutionKind::Classic,
826            Self::Node10 => ModuleResolutionKind::Node,
827            Self::Node16 => ModuleResolutionKind::Node16,
828            Self::NodeNext => ModuleResolutionKind::NodeNext,
829            Self::Bundler => ModuleResolutionKind::Bundler,
830        }
831    }
832}
833
834#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
835pub enum ModuleDetection {
836    /// Files with imports, exports, import.meta, jsx, or esm format are modules.
837    Auto,
838    /// Every non-declaration file is a module.
839    Force,
840    /// Only files with imports or exports are modules.
841    Legacy,
842}
843
844#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
845pub enum NewLine {
846    /// Use carriage return followed by line feed (\\r\\n).
847    Crlf,
848    /// Use line feed only (\\n).
849    Lf,
850}
851
852#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
853pub enum WatchFileKind {
854    /// Poll files at fixed intervals.
855    #[value(name = "fixedpollinginterval", alias = "fixed-polling-interval")]
856    FixedPollingInterval,
857    /// Poll files with priority intervals.
858    #[value(name = "prioritypollinginterval", alias = "priority-polling-interval")]
859    PriorityPollingInterval,
860    /// Poll files dynamically based on activity.
861    #[value(name = "dynamicprioritypolling", alias = "dynamic-priority-polling")]
862    DynamicPriorityPolling,
863    /// Poll using fixed chunk sizes.
864    #[value(name = "fixedchunksizepolling", alias = "fixed-chunk-size-polling")]
865    FixedChunkSizePolling,
866    /// Use native file system events.
867    #[value(name = "usefsevents", alias = "use-fs-events")]
868    UseFsEvents,
869    /// Use file system events on parent directory.
870    #[value(
871        name = "usefseventsonparentdirectory",
872        alias = "use-fs-events-on-parent-directory"
873    )]
874    UseFsEventsOnParentDirectory,
875}
876
877#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
878pub enum WatchDirectoryKind {
879    /// Use native file system events for directories.
880    #[value(name = "usefsevents", alias = "use-fs-events")]
881    UseFsEvents,
882    /// Poll directories at fixed intervals.
883    #[value(name = "fixedpollinginterval", alias = "fixed-polling-interval")]
884    FixedPollingInterval,
885    /// Poll directories dynamically based on activity.
886    #[value(name = "dynamicprioritypolling", alias = "dynamic-priority-polling")]
887    DynamicPriorityPolling,
888    /// Poll directories using fixed chunk sizes.
889    #[value(name = "fixedchunksizepolling", alias = "fixed-chunk-size-polling")]
890    FixedChunkSizePolling,
891}
892
893#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
894pub enum PollingWatchKind {
895    /// Poll at fixed intervals as fallback.
896    #[value(name = "fixedinterval", alias = "fixed-interval")]
897    FixedInterval,
898    /// Poll with priority intervals as fallback.
899    #[value(name = "priorityinterval", alias = "priority-interval")]
900    PriorityInterval,
901    /// Poll dynamically as fallback.
902    #[value(name = "dynamicpriority", alias = "dynamic-priority")]
903    DynamicPriority,
904    /// Poll using fixed chunk sizes as fallback.
905    #[value(name = "fixedchunksize", alias = "fixed-chunk-size")]
906    FixedChunkSize,
907}
908
909#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
910pub enum ImportsNotUsedAsValues {
911    /// Drop import statements which only reference types.
912    Remove,
913    /// Preserve all import statements.
914    Preserve,
915    /// Error on import statements that only reference types.
916    Error,
917}