pub(crate) struct AssignOpts {
Show 31 fields pub span: Span, pub right_ident_span: Option<Span>, pub left_ident_span: Option<Span>, pub allow_unknown_rhs: Option<bool>, pub allow_missing_fields: bool, pub allow_unknown_type: bool, pub allow_assignment_to_param: bool, pub allow_assignment_of_param: bool, pub skip_call_and_constructor_elem: bool, pub for_overload: bool, pub disallow_assignment_to_unknown: bool, pub for_castablity: bool, pub disallow_special_assignment_to_empty_class: bool, pub disallow_different_classes: bool, pub allow_iterable_on_rhs: bool, pub allow_assignment_of_void: Option<bool>, pub allow_assignment_to_void: bool, pub allow_assignment_of_array_to_optional_type_lit: bool, pub use_missing_fields_for_class: bool, pub allow_assignment_to_param_constraint: bool, pub may_unwrap_promise: bool, pub allow_unknown_rhs_if_expanded: bool, pub infer_type_params_of_left: bool, pub is_assigning_to_class_members: bool, pub is_params_of_method_definition: bool, pub treat_array_as_interfaces: bool, pub do_not_convert_enum_to_string_nor_number: bool, pub ignore_enum_variant_name: bool, pub ignore_tuple_length_difference: bool, pub do_not_normalize_intersection_on_rhs: bool, pub report_assign_failure_for_missing_properties: Option<bool>,
}
Expand description

Context used for = assignments.

Fields

span: Span

This field should be overriden by caller.

right_ident_span: Option<Span>left_ident_span: Option<Span>allow_unknown_rhs: Option<bool>

Values

  • Some(false): inexact and specified of [TypeLitMetadata] are ignored.
  • Some(true): extra properties are allowed.
  • None: It depends on inexact and specified of [TypeLitMetadata]

Usages

  • Some(false) is Used for extends check.
allow_missing_fields: boolallow_unknown_type: bool

Allow assigning unknown type to other types. This should be true for parameters because the following is valid.

  declare var a: {
    (a:[2]): void
  }

  declare var b: {
    (a:[unknown]): void
  }

  a = b;
allow_assignment_to_param: bool

Allow assignment to Type::Param.

allow_assignment_of_param: boolskip_call_and_constructor_elem: boolfor_overload: booldisallow_assignment_to_unknown: boolfor_castablity: bool

This is true for variable overloads, too. This will be fixed in future.

disallow_special_assignment_to_empty_class: bool

If this is false, assignment of literals or some other strange type to empty class will success.

disallow_different_classes: bool

If true, assignment of a class to another class without inheritance relation will fail, even if the class is empty.

allow_iterable_on_rhs: bool

If true, assign will try to assign by converting rhs to an iterable.

allow_assignment_of_void: Option<bool>

If true, assignment will success if rhs is void. None means false.

This is Option because it’s required.

allow_assignment_to_void: bool

If true, assignment will success if lhs is void.

allow_assignment_of_array_to_optional_type_lit: booluse_missing_fields_for_class: boolallow_assignment_to_param_constraint: boolmay_unwrap_promise: bool

The code below is valid.

declare var p: Promise<Promise<string>>

async function foo(): Promise<string> {
    return p
}
allow_unknown_rhs_if_expanded: bool

contextualTYpeWithUnionTypeMembers says

When used as a contextual type, a union type U has those members that are present in any of its constituent types, with types that are unions of the respective members in the constituent types.

And

var i1Ori2: I1<number> | I2<number> = { // Like i1 and i2 both
    commonPropertyType: "hello",
    commonMethodType: a=> a,
    commonMethodWithTypeParameter: a => a,
    methodOnlyInI1: a => a,
    propertyOnlyInI1: "Hello",
    methodOnlyInI2: a => a,
    propertyOnlyInI2: "Hello",
};

is valid but

function f13(x: { a: null; b: string } | { a: string, c: number }) {
    x = { a: null, b: "foo", c: 4};  // Error
}

and

var test: { a: null; b: string } | { a: string, c: number } = { a: null, b: "foo", c: 4}

are not.

infer_type_params_of_left: boolis_assigning_to_class_members: boolis_params_of_method_definition: booltreat_array_as_interfaces: booldo_not_convert_enum_to_string_nor_number: boolignore_enum_variant_name: boolignore_tuple_length_difference: booldo_not_normalize_intersection_on_rhs: bool

Used to prevent recursion

report_assign_failure_for_missing_properties: Option<bool>

Use TS2322 on missing properties.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more