Skip to main content

tsz_checker/
lib.rs

1//! Type checker module for TypeScript AST.
2//!
3//! This module is organized into several submodules:
4//! - `context` - `CheckerContext` for shared state
5//! - `expr` - Expression type checking
6//! - `statements` - Statement type checking
7//! - `declarations` - Declaration type checking
8//! - `flow_graph_builder` - Control flow graph builder
9//! - `flow_analyzer` - Definite assignment analysis
10//! - `reachability_analyzer` - Unreachable code detection
11//! - `control_flow` - Flow analyzer for type narrowing
12//! - `error_reporter` - Error reporting utilities
13//!
14//! Note: The thin checker is the unified checker pipeline; `CheckerState`
15//! is an alias to the thin checker.
16
17extern crate self as tsz_checker;
18
19pub mod context;
20pub mod dispatch;
21pub mod error_reporter;
22pub mod expr;
23pub mod judge_integration;
24pub mod module_resolution;
25pub mod optional_chain;
26mod query_boundaries;
27pub mod statements;
28pub mod triple_slash_validator;
29
30#[path = "assignability/mod.rs"]
31mod assignability_domain;
32#[path = "checkers/mod.rs"]
33mod checkers_domain;
34#[path = "classes/mod.rs"]
35mod classes_domain;
36#[path = "declarations/mod.rs"]
37mod declarations_domain;
38#[path = "flow/mod.rs"]
39mod flow_domain;
40#[path = "state/mod.rs"]
41mod state_domain;
42#[path = "symbols/mod.rs"]
43mod symbols_domain;
44#[path = "types/mod.rs"]
45mod types_domain;
46
47pub use checkers_domain::{
48    accessor_checker, call_checker, enum_checker, generic_checker, iterable_checker, jsx_checker,
49    parameter_checker, promise_checker, property_checker, signature_builder,
50};
51
52pub use assignability_domain::{
53    assignability_checker, assignment_checker, subtype_identity_checker,
54};
55
56pub use classes_domain::{
57    class_checker, class_inheritance, constructor_checker, private_checker, super_checker,
58};
59
60pub use declarations_domain::{declarations, import_checker, module_checker, namespace_checker};
61
62pub use flow_domain::{
63    control_flow, flow_analysis, flow_analyzer, flow_graph_builder, reachability_analyzer,
64    reachability_checker,
65};
66
67pub use state_domain::{
68    state, state_checking, state_type_analysis, state_type_environment, state_type_resolution,
69};
70
71pub use symbols_domain::{scope_finder, symbol_resolver};
72
73pub use types_domain::{
74    class_type, function_type, interface_type, literal_type, object_type, type_checking,
75    type_computation, type_literal_checker, type_node,
76};
77
78pub mod diagnostics {
79    pub use tsz_common::diagnostics::{
80        Diagnostic, DiagnosticCategory, DiagnosticRelatedInformation, diagnostic_codes,
81        diagnostic_messages, format_message,
82    };
83}
84
85// Tests that don't depend on root crate's test_fixtures
86#[cfg(test)]
87#[path = "../tests/conformance_issues.rs"]
88mod conformance_issues;
89#[cfg(test)]
90#[path = "../tests/control_flow_tests.rs"]
91mod control_flow_tests;
92#[cfg(test)]
93#[path = "../tests/control_flow_type_guard_tests.rs"]
94mod control_flow_type_guard_tests;
95#[cfg(test)]
96#[path = "../tests/definite_assignment_tests.rs"]
97mod definite_assignment_tests;
98#[cfg(test)]
99#[path = "../tests/enum_member_cache_tests.rs"]
100mod enum_member_cache_tests;
101#[cfg(test)]
102#[path = "../tests/enum_merge_tests.rs"]
103mod enum_merge_tests;
104#[cfg(test)]
105#[path = "../tests/no_filename_based_behavior_tests.rs"]
106mod no_filename_based_behavior_tests;
107#[cfg(test)]
108#[path = "../tests/rest_parameter_tests.rs"]
109mod rest_parameter_tests;
110#[cfg(test)]
111#[path = "../tests/spread_rest_tests.rs"]
112mod spread_rest_tests;
113#[cfg(test)]
114#[path = "../tests/stability_validation_tests.rs"]
115mod stability_validation_tests;
116#[cfg(test)]
117#[path = "../tests/string_literal_arithmetic_tests.rs"]
118mod string_literal_arithmetic_tests;
119#[cfg(test)]
120#[path = "../tests/symbol_resolver_stability_tests.rs"]
121mod symbol_resolver_stability_tests;
122#[cfg(test)]
123#[path = "../tests/ts1214_let_strict_mode_tests.rs"]
124mod ts1214_let_strict_mode_tests;
125#[cfg(test)]
126#[path = "../tests/ts2300_tests.rs"]
127mod ts2300_tests;
128#[cfg(test)]
129#[path = "../tests/ts2322_mode_routing_matrix.rs"]
130mod ts2322_mode_routing_matrix;
131#[cfg(test)]
132#[path = "../tests/ts2322_tests.rs"]
133mod ts2322_tests;
134#[cfg(test)]
135#[path = "../tests/ts2323_tests.rs"]
136mod ts2323_tests;
137#[cfg(test)]
138#[path = "../tests/ts2411_tests.rs"]
139mod ts2411_tests;
140#[cfg(test)]
141#[path = "../tests/ts2430_tests.rs"]
142mod ts2430_tests;
143#[cfg(test)]
144#[path = "../tests/ts2540_readonly_tests.rs"]
145mod ts2540_readonly_tests;
146#[cfg(test)]
147#[path = "../tests/ts2558_new_type_args_tests.rs"]
148mod ts2558_new_type_args_tests;
149#[cfg(test)]
150#[path = "../tests/ts2774_tests.rs"]
151mod ts2774_tests;
152#[cfg(test)]
153#[path = "../tests/ts6133_unused_type_params_tests.rs"]
154mod ts6133_unused_type_params_tests;
155#[cfg(test)]
156#[path = "../tests/ts7057_yield_implicit_any.rs"]
157mod ts7057_yield_implicit_any;
158#[cfg(test)]
159#[path = "../tests/value_usage_tests.rs"]
160mod value_usage_tests;
161// Tests kept in root test harness where shared fixtures live.
162#[cfg(test)]
163#[path = "../tests/architecture_contract_tests.rs"]
164mod architecture_contract_tests;
165#[cfg(test)]
166#[path = "tests/architecture_contract_tests.rs"]
167mod architecture_contract_tests_src;
168#[cfg(test)]
169#[path = "../tests/class_index_signature_compat_tests.rs"]
170mod class_index_signature_compat_tests;
171#[cfg(test)]
172#[path = "../tests/conditional_keyof_test.rs"]
173mod conditional_keyof_test;
174#[cfg(test)]
175#[path = "../tests/enum_nominality_tests.rs"]
176mod enum_nominality_tests;
177#[cfg(test)]
178#[path = "../tests/flow_boundary_contract_tests.rs"]
179mod flow_boundary_contract_tests;
180#[cfg(test)]
181#[path = "../tests/generic_inference_manual.rs"]
182mod generic_inference_manual;
183#[cfg(test)]
184#[path = "../tests/generic_tests.rs"]
185mod generic_tests;
186#[cfg(test)]
187#[path = "../tests/member_access_architecture_boundary_tests.rs"]
188mod member_access_architecture_boundary_tests;
189#[cfg(test)]
190#[path = "../tests/module_resolution_guard_tests.rs"]
191mod module_resolution_guard_tests;
192#[cfg(test)]
193#[path = "../tests/private_brands.rs"]
194mod private_brands;
195#[cfg(test)]
196#[path = "../tests/repro_parserreal.rs"]
197mod repro_parserreal;
198#[cfg(test)]
199#[path = "../tests/strict_null_manual.rs"]
200mod strict_null_manual;
201
202// Re-export key types
203pub use context::{CheckerContext, CheckerOptions, EnclosingClassInfo, TypeCache};
204pub use control_flow::{FlowAnalyzer, FlowGraph as ControlFlowGraph};
205pub use declarations::DeclarationChecker;
206pub use dispatch::ExpressionDispatcher;
207pub use expr::ExpressionChecker;
208pub use flow_analyzer::{
209    AssignmentState, AssignmentStateMap, DefiniteAssignmentAnalyzer, DefiniteAssignmentResult,
210    merge_assignment_states,
211};
212pub use flow_graph_builder::{FlowGraph, FlowGraphBuilder};
213pub use reachability_analyzer::ReachabilityAnalyzer;
214pub use state::{CheckerState, MAX_CALL_DEPTH, MAX_INSTANTIATION_DEPTH};
215pub use statements::{StatementCheckCallbacks, StatementChecker};
216pub use tsz_solver::Visibility;
217pub use type_node::TypeNodeChecker;