stc
stc copied to clipboard
Modify function type on property assignment
Problem
https://github.com/dudykr/stc/blob/efd873e395fb9327f6cbd8be76a24678013269c4/crates/stc_ts_type_checker/tests/conformance/salsa/typeFromPropertyAssignment29.ts#L2-L9
Currently, stc does not support adding a property to type by assigning a property to function. But the function type is special, and we should support it.
Hi, I would like to take a look at this issue, but I am not sure how to proceed with this. This is what I have thought of so far:
- I probably have to modify
access_property_inner()
incrates/stc_ts_file_analyzer/src/analyzer/expr/mod.rs
when checking property access forType::Function
. - I will need to modify the
Function
struct incrates/stc_ts_types/src/lib.rs
, so that we have a place to store function properties.
I am not sure where is the best place for the logic to update the Function
struct with the function properties though.
I think the ideal way is to add a type literal (for intersection) on each assignment, not access_property
Shared mutability is a hard topic in rust. Actually, we don't mutate types from multiple threads, so we don't need a mutex but Type
has to be Send
, and it's sometimes wrapped in Arc
to reduce memory usage. So we should not modify it in-place
I think that this function type mean Module type module type is callable and have a property
and
ts playground says next