tsz-checker 0.1.9

TypeScript type checker for the tsz compiler
Documentation
use super::state_checking;
use crate::flow_analysis::PropertyKey;
use crate::state::CheckerState;
use rustc_hash::FxHashSet;
use tsz_binder::SymbolId;
use tsz_parser::parser::NodeIndex;
use tsz_solver::TypeId;

pub(crate) fn constructor_assigned_properties(
    state: &CheckerState<'_>,
    body_idx: NodeIndex,
    tracked: &FxHashSet<PropertyKey>,
    _require_super: bool,
) -> FxHashSet<PropertyKey> {
    state.analyze_constructor_assignments(body_idx, tracked, false)
}

pub(crate) fn check_constructor_property_use_before_assignment(
    state: &mut CheckerState<'_>,
    body_idx: NodeIndex,
    tracked: &FxHashSet<PropertyKey>,
    _require_super: bool,
) {
    state.check_properties_used_before_assigned(body_idx, tracked, false);
}

pub(crate) fn should_report_variable_use_before_assignment(
    state: &mut CheckerState<'_>,
    idx: NodeIndex,
    declared_type: TypeId,
    sym_id: SymbolId,
) -> bool {
    state.should_check_definite_assignment(sym_id, idx)
        && !state.skip_definite_assignment_for_type(declared_type)
        && !state.is_definitely_assigned_at(idx)
}

pub(crate) fn find_property_in_object_by_str(
    state: &CheckerState<'_>,
    type_id: TypeId,
    property: &str,
) -> Option<tsz_solver::PropertyInfo> {
    state_checking::find_property_in_object_by_str(state.ctx.types, type_id, property)
}