Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuple modification by method diagnostics #170

Open
kaleidawave opened this issue Jun 24, 2024 · 0 comments
Open

Tuple modification by method diagnostics #170

kaleidawave opened this issue Jun 24, 2024 · 0 comments
Labels
checking Issues around checking diagnostics related to outputting code errors

Comments

@kaleidawave
Copy link
Owner

Currently tuple annotations also make their length a constraint.

So the following fails because { ... length: 3 } is not assignable to { ... length: 2 }

const x: [1, 2] = [1, 2, 3]

This is TSC behavior for all subtyping


Now thanks to #18 and .push unfolding. x.push(5) currently fails because it tries to assign to the length.

The problem is this just raises the usual Parameter assignment mismatch. It would be good if it could detect the constraint is a tuple and the length is being modified then it could throw a different diagnostic?

The one problem is that currently pop also tries to modify the value, so two assignment mismatches are thrown. Maybe events could short-circuit? Or go into unknown mode? Or don't print the second assignment mismatch? Or something?

@kaleidawave kaleidawave added checking Issues around checking diagnostics related to outputting code errors labels Jun 24, 2024
@kaleidawave kaleidawave changed the title Tuple assignment constraint Tuple modification by method diagnostics Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checking Issues around checking diagnostics related to outputting code errors
Projects
None yet
Development

No branches or pull requests

1 participant