Struct stc_ts_file_analyzer::analyzer::assign::AssignOpts
source · [−]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
andspecified
of [TypeLitMetadata] are ignored.Some(true)
: extra properties are allowed.None
: It depends oninexact
andspecified
of [TypeLitMetadata]
Usages
Some(false)
is Used forextends
check.
allow_missing_fields: bool
allow_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: bool
skip_call_and_constructor_elem: bool
for_overload: bool
disallow_assignment_to_unknown: bool
for_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: bool
use_missing_fields_for_class: bool
allow_assignment_to_param_constraint: bool
may_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: bool
is_assigning_to_class_members: bool
is_params_of_method_definition: bool
treat_array_as_interfaces: bool
do_not_convert_enum_to_string_nor_number: bool
ignore_enum_variant_name: bool
ignore_tuple_length_difference: bool
do_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
sourceimpl Clone for AssignOpts
impl Clone for AssignOpts
sourcefn clone(&self) -> AssignOpts
fn clone(&self) -> AssignOpts
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more