tsz_checker/
judge_integration.rs1use crate::state::CheckerState;
6use tsz_solver::TypeId;
7use tsz_solver::judge::{DefaultJudge, Judge, JudgeConfig};
8
9impl<'a> CheckerState<'a> {
10 pub fn with_judge<R, F>(&self, f: F) -> R
16 where
17 F: FnOnce(&DefaultJudge<'_>) -> R,
18 {
19 let env = self.ctx.type_env.borrow();
20 let config = JudgeConfig {
21 strict_null_checks: self.ctx.strict_null_checks(),
22 strict_function_types: self.ctx.strict_function_types(),
23 exact_optional_property_types: self.ctx.exact_optional_property_types(),
24 no_unchecked_indexed_access: self.ctx.no_unchecked_indexed_access(),
25 sound_mode: self.ctx.sound_mode(),
26 };
27 let judge = DefaultJudge::new(self.ctx.types, &env, config);
28 f(&judge)
29 }
30
31 pub fn judge_evaluate(&self, type_id: TypeId) -> TypeId {
35 self.with_judge(|judge| judge.evaluate(type_id))
36 }
37}