Struct stc_ts_types::metadata::TypeLitMetadata
source · [−]pub struct TypeLitMetadata {
pub common: CommonTypeMetadata,
pub inexact: bool,
pub normalized: bool,
pub specified: bool,
}
Fields
common: CommonTypeMetadata
inexact: bool
true
if a spread element is used while initializing.
normalized: bool
true
if a type literal is modified by object union normalizer.
specified: bool
true
if a type literal is declared by user or created from other
user-declared types like crate::Interface or etc..
Note
specified
for a
in the code below should be changed to false
declare var a: { a: string }
const b = [a, {b: 'foo'}]
because b
is normalized and so that the the code above is validated.
But it should be true
for the code below (copied from
objectLiteralNormalization.ts
).
declare function f<T>(...items: T[]): T;
declare let data: { a: 1, b: "abc", c: true };
// Object literals are inferred as a single normalized union type
let e1 = f({ a: 1, b: 2 }, { a: "abc" }, {});
let e2 = f({}, { a: "abc" }, { a: 1, b: 2 });
let e3 = f(data, { a: 2 }); // error
let e4 = f({ a: 2 }, data); // error
because tsc selects type of data
instead of a normalized type literal
union if one of inferred type literal is specified
.
Trait Implementations
sourceimpl Clone for TypeLitMetadata
impl Clone for TypeLitMetadata
sourcefn clone(&self) -> TypeLitMetadata
fn clone(&self) -> TypeLitMetadata
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for TypeLitMetadata
impl Debug for TypeLitMetadata
sourceimpl Default for TypeLitMetadata
impl Default for TypeLitMetadata
sourcefn default() -> TypeLitMetadata
fn default() -> TypeLitMetadata
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for TypeLitMetadata
impl<'de> Deserialize<'de> for TypeLitMetadata
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl EqIgnoreSpan for TypeLitMetadata
impl EqIgnoreSpan for TypeLitMetadata
Note
This struct is treated as a span while comparison. It means, EqIgnoreSpan will always return true.
fn eq_ignore_span(&self, _: &Self) -> bool
sourceimpl<F: ?Sized> FoldWith<F> for TypeLitMetadata
impl<F: ?Sized> FoldWith<F> for TypeLitMetadata
Noop.
sourceimpl PartialEq<TypeLitMetadata> for TypeLitMetadata
impl PartialEq<TypeLitMetadata> for TypeLitMetadata
sourcefn eq(&self, other: &TypeLitMetadata) -> bool
fn eq(&self, other: &TypeLitMetadata) -> bool
sourceimpl Serialize for TypeLitMetadata
impl Serialize for TypeLitMetadata
sourceimpl TypeEq for TypeLitMetadata
impl TypeEq for TypeLitMetadata
sourceimpl TypeMetadata for TypeLitMetadata
impl TypeMetadata for TypeLitMetadata
fn common(&self) -> CommonTypeMetadata
sourceimpl<F: ?Sized> VisitMutWith<F> for TypeLitMetadata
impl<F: ?Sized> VisitMutWith<F> for TypeLitMetadata
Noop.
fn visit_mut_children_with(&mut self, _: &mut F)
fn visit_mut_with(&mut self, visitor: &mut V)where
V: VisitMut<Self>,
sourceimpl<F: ?Sized> VisitWith<F> for TypeLitMetadata
impl<F: ?Sized> VisitWith<F> for TypeLitMetadata
Noop.
fn visit_children_with(&self, _: &mut F)
fn visit_with(&self, visitor: &mut V)where
V: Visit<Self>,
impl Copy for TypeLitMetadata
impl Eq for TypeLitMetadata
impl StructuralEq for TypeLitMetadata
impl StructuralPartialEq for TypeLitMetadata
impl Visitable for TypeLitMetadata
Auto Trait Implementations
impl RefUnwindSafe for TypeLitMetadata
impl Send for TypeLitMetadata
impl Sync for TypeLitMetadata
impl Unpin for TypeLitMetadata
impl UnwindSafe for TypeLitMetadata
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<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.