Struct stc_ts_types::type_id::ClassId
source · [−]pub struct ClassId(u64);
Expand description
Used to distinguish private class properties.
Context
derivedClassTransitivity.ts
:
// subclassing is not transitive when you can remove required parameters and add optional parameters
class C {
foo(x: number) { }
}
class D extends C {
foo() { } // ok to drop parameters
}
class E extends D {
foo(x?: string) { } // ok to add optional parameters
}
var c: C;
var d: D;
var e: E;
c = e;
var r = c.foo(1);
var r2 = e.foo('');
As derived class may have different signature than parent class, we can’t use super class to assign classes.
Because of it, we should assign properties directly.
It means we need a way to know if two class properties are exactly identical i.e. declared in same class.
Note
Alternative
[WIP] (Seeing if span is enough)
lo
and hi
of a swc_common::Span can be also used to check if two
private properties are identical, but I(kdy1) decided to use a new type
because
Not data
This is not data
part of class and as a result type_eq
and
eq_ignore_span
always return true
.
Tuple Fields
0: u64
Implementations
Trait Implementations
sourceimpl<V> VisitMutWith<V> for ClassIdwhere
V: ?Sized,
impl<V> VisitMutWith<V> for ClassIdwhere
V: ?Sized,
fn visit_mut_children_with(&mut self, _visitor: &mut V)
fn visit_mut_with(&mut self, visitor: &mut V)where
V: VisitMut<Self>,
sourceimpl<V> VisitWith<V> for ClassIdwhere
V: ?Sized,
impl<V> VisitWith<V> for ClassIdwhere
V: ?Sized,
fn visit_children_with(&self, _visitor: &mut V)
fn visit_with(&self, visitor: &mut V)where
V: Visit<Self>,
impl Copy for ClassId
impl Eq for ClassId
impl StructuralEq for ClassId
impl StructuralPartialEq for ClassId
impl Visitable for ClassId
Auto Trait Implementations
impl RefUnwindSafe for ClassId
impl Send for ClassId
impl Sync for ClassId
impl Unpin for ClassId
impl UnwindSafe for ClassId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for Twhere
T: Hash + ?Sized,
impl<T> CallHasher for Twhere
T: Hash + ?Sized,
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.