1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/// Options for type checking
/// TODO figure out compat with tsc
#[cfg_attr(feature = "serde-serialize", derive(serde::Deserialize), serde(default))]
#[cfg_attr(target_family = "wasm", derive(tsify::Tsify))]
#[allow(clippy::struct_excessive_bools)]
pub struct TypeCheckOptions {
	/// Parameters cannot be reassigned
	pub constant_parameters: bool,

	/// Missing arguments are treated as undefined (thats how JS works)
	pub allow_elided_arguments: bool,

	/// Addition arguments are allowed
	pub allow_extra_arguments: bool,

	/// Given a `function x`, `x = 2` is not possible
	pub constant_function_declarations: bool,

	/// Whether auto casts can happen. aka `{} + 2` is allowed using the Object's primitive default
	/// TODO maybe levels
	pub strict_casts: bool,

	/// Any types displayed will be in debug view
	pub debug_types: bool,

	/// Enables `as` casts
	pub allow_cast: bool,

	/// For post type check optimisations and
	pub store_expression_type_mappings: bool,

	/// TODO WIP
	pub parse_comments: bool,

	/// Allows partial syntax and collects other information for using in editor
	pub lsp_mode: bool,
}

impl Default for TypeCheckOptions {
	fn default() -> Self {
		Self {
			constant_parameters: false,
			allow_elided_arguments: false,
			allow_extra_arguments: false,
			constant_function_declarations: true,
			debug_types: false,
			parse_comments: true,
			strict_casts: false,
			store_expression_type_mappings: false,
			lsp_mode: false,
			// TODO false at some point hopefully!
			allow_cast: true,
		}
	}
}