-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Pick doesn't validate correctly #55735
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
Comments
This is working as intended. Objects are allowed to have additional properties. Only in specific cases (like assignment of object literals) an "excess property check" is performed, but this is more of a linter feature than part of the type system. And please fill out the issue template correctly. The "Code" section is empty and the search terms you used are excessive. And TypeScript 4.0.7 is ancient. You might want to update. |
Thanks for the quick response (and I fixed my ticket, sorry about that). While I agree that objects can have additional properties, this inconsistency is confusing and conflicting. |
It's not inconsistent, and confusing only for beginners. TypeScript has a structural type system, and only object literals get excess property checks. You might be interested in #12936, but don't expect it any time soon. |
I thought TypeScript's mission is to help all levels of developers, to say it's confusing only for beginners kind of defeats the purpose of having it. That proposal does looks great, thanks for sharing. |
@guohaolay It's known that the current error message for excess property check is confusing and suggests a type rule that doesn't actually exist. The message will change in 5.3, see #55152 |
π Search Terms
Pick, linter
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgCoHsAm7kG8BQyyYwYANhAFzIDOYUoA5gNyHKYQ0IMAOJ6IanQYgWbBOgC2PCpEzUARunQU4IVgF98+MAE8eKDNgAKUCADdgEAO7IAvMmPAEAawA8R9ABpkAIhLkEL7IAD5+EtKyEJi+AHys+BIgdOxwYHCUnvZ4bAEU1L4AwqogyFDKkr5e4lIyEHLU8GQ0ENVEHFy8-IK+AIwATADMVfgaCUkpYFjo1J6mFla2DphpcAlT2KwA9FvIAHoA-EA
π» Code
π Actual behavior
No error reported
π Expected behavior
Error should be reported
Additional information about the issue
Pick does not validate correctly if using an object with more keys than the Picked key.
The text was updated successfully, but these errors were encountered: