Struct stc_ts_file_analyzer::ty::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<TypeLitMetadata, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<TypeLitMetadata, <__D as Deserializer<'de>>::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, &TypeLitMetadata) -> bool
sourceimpl<F> FoldWith<F> for TypeLitMetadatawhere
F: ?Sized,
impl<F> FoldWith<F> for TypeLitMetadatawhere
F: ?Sized,
Noop.
fn fold_children_with(self, &mut F) -> TypeLitMetadata
fn fold_with(self, visitor: &mut V) -> Selfwhere
V: Fold<Self>,
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
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl TypeEq for TypeLitMetadata
impl TypeEq for TypeLitMetadata
sourcefn type_eq(&self, &TypeLitMetadata) -> bool
fn type_eq(&self, &TypeLitMetadata) -> bool
Note: This method should return
true
for non-type values.sourceimpl TypeMetadata for TypeLitMetadata
impl TypeMetadata for TypeLitMetadata
fn common(&self) -> CommonTypeMetadata
sourceimpl<F> VisitMutWith<F> for TypeLitMetadatawhere
F: ?Sized,
impl<F> VisitMutWith<F> for TypeLitMetadatawhere
F: ?Sized,
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> VisitWith<F> for TypeLitMetadatawhere
F: ?Sized,
impl<F> VisitWith<F> for TypeLitMetadatawhere
F: ?Sized,
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.