Skip to content

satisfies allows excess properties via object spread #50938

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

Closed
robpalme opened this issue Sep 24, 2022 · 1 comment
Closed

satisfies allows excess properties via object spread #50938

robpalme opened this issue Sep 24, 2022 · 1 comment

Comments

@robpalme
Copy link

Bug Report

πŸ”Ž Search Terms

satisfies object spread excess properties

πŸ•— Version & Regression Information

  • Tested on 4.9.0-dev.20220921

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type Colors = "red" | "green" | "blue";

const favoriteColors = {
    "red": "yes",
    "green": false,
    "blue": "kinda",
    ...{ platypus: false },   // No error, despite it being a known excess property
} satisfies Record<Colors, unknown>;

πŸ™ Actual behavior

No error. The use of object spread causes the excess property to be permitted.

Hovering over favoriteColors, you can see that TypeScript understands it has generated a type with all four properties.

πŸ™‚ Expected behavior

An error. The issue introducing satisfies and release notes suggest excess property detection is an intended feature of satisfies.

@robpalme
Copy link
Author

This issue is not specific to satisfies and is a known limitation of the existing excess property checks.

There is already a request to make the checking stricter to include object spread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant