1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use rnode::{Visit, VisitWith};
use stc_ts_types::Type;
pub fn contains_this(ty: &Type) -> bool {
let mut v = ThisFinder::default();
ty.visit_with(&mut v);
v.found
}
#[derive(Default)]
struct ThisFinder {
found: bool,
}
impl Visit<Type> for ThisFinder {
fn visit(&mut self, ty: &Type) {
ty.visit_children_with(self);
if let Type::This(..) = ty.normalize() {
self.found = true;
}
}
}