stc: Allow assignment of tuples with different length if it's `undefined` or `any`
This line should not report an argumentnt error because fields are optional.
The type of arguments are correctly inferred as [any, any, any, any] but we should allow assignment of [1] to [any, any, any, any].
The assignment logic for tuple should be aware of any or undefined and allow the length to mismatch for these cases.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 20 (20 by maintainers)
Of course, thank you!
Not sure. You can search for
RPat::Assignusing IDE to look at possible cases.I expect it to be one of
https://github.com/dudykr/stc/blob/d8b849c672f033c1e0a04caf9737f9a6ae7c6863/crates/stc_ts_file_analyzer/src/analyzer/pat.rs#L144
https://github.com/dudykr/stc/blob/d8b849c672f033c1e0a04caf9737f9a6ae7c6863/crates/stc_ts_file_analyzer/src/analyzer/pat.rs#L276-L285
https://github.com/dudykr/stc/blob/d8b849c672f033c1e0a04caf9737f9a6ae7c6863/crates/stc_ts_file_analyzer/src/analyzer/pat.rs#L316-L374
https://github.com/dudykr/stc/blob/d8b849c672f033c1e0a04caf9737f9a6ae7c6863/crates/stc_ts_file_analyzer/src/analyzer/scope/vars.rs#L158-L217
https://github.com/dudykr/stc/blob/d8b849c672f033c1e0a04caf9737f9a6ae7c6863/crates/stc_ts_file_analyzer/src/analyzer/scope/vars.rs#L275-L291
Oh, then there’s
Type::OptionalYou have two options.
./scripts/test.sh yourTestNamewill work, but if you want to reduce it further, you can copy it to tests directory of the file analyzerhttps://github.com/dudykr/stc/tree/2ab93ad46cd2683539300bde8f30c7bf89ac1e15/crates/stc_ts_file_analyzer/tests