stc: Allow assignment of tuples with different length if it's `undefined` or `any`

https://github.com/dudykr/stc/blob/e59631e58fb04578142befb6e5dbc7ef1d52f9db/crates/stc_ts_type_checker/tests/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts#L9-L10

This line should not report an argumentnt error because fields are optional.

image

The type of arguments are correctly inferred as [any, any, any, any] but we should allow assignment of [1] to [any, any, any, any].

https://github.com/dudykr/stc/blob/e59631e58fb04578142befb6e5dbc7ef1d52f9db/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs#L1999-L2010

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)

Most upvoted comments