Question about excess property checks and an opt-in strict option #4453
Replies: 1 comment 1 reply
|
If you say that excess properties are never allowed in the subtype/assignability relation, you quickly run into problems. For example, the difference between You need some way to distinguish cases which are OK with excess properties and cases that aren't, which is basically just the "exact types" proposal you can find in the TS issue tracker. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hey! I've been reading through the typescript-go checker to learn how it works, and a question came up.
I noticed excess property checks only catch object literals directly. Like, this errors:
but if I store it in a variable first, it slips through:
I know TS is structural on purpose so JS projects can migrate gradually, and that being strict by default would break everything.
But these days a lot of systems start as 100% TS. Would it make sense to have an opt-in option (like a tsconfig flag) to be stricter in those cases?
Just an idea, and I'm probably missing something. Is something like this doable, or is there a reason it wouldn't work? Mostly just curious and trying to learn.
Thanks!
All reactions