-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
π Search Terms
Pick, linter
π Version & Regression Information
- This is the behavior in version 4.0.7, and whatever the TypeScript playground uses
β― Playground Link
π» Code
interface Todo {
title: string;
description: string;
completed: boolean;
}
type TodoPreview = Pick<Todo, "title" | "completed">;
const data:Todo = {
title: "Clean room",
completed: false,
description:"123",
};
// TypeScript correctly identifies the extra key `description`:
const todo: TodoPreview = {
title: "Clean room",
completed: false,
description:"123",
};
// But doesn't pick up if assigned this way:
const todo2: TodoPreview = data;
π 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.
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug