🔎 Search Terms
Pick, linter
🕗 Version & Regression Information
- This is the behavior in version 4.0.7, and whatever the TypeScript playground uses
⏯ Playground Link
https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgCoHsAm7kG8BQyyYwYANhAFzIDOYUoA5gNyHKYQ0IMAOJ6IanQYgWbBOgC2PCpEzUARunQU4IVgF98+MAE8eKDNgAKUCADdgEAO7IAvMmPAEAawA8R9ABpkAIhLkEL7IAD5+EtKyEJi+AHys+BIgdOxwYHCUnvZ4bAEU1L4AwqogyFDKkr5e4lIyEHLU8GQ0ENVEHFy8-IK+AIwATADMVfgaCUkpYFjo1J6mFla2DphpcAlT2KwA9FvIAHoA-EA
💻 Code
interfaceTodo{title: string;description: string;completed: boolean;}typeTodoPreview=Pick<Todo,"title"|"completed">;constdata:Todo={title: "Clean room",completed: false,description:"123",};// TypeScript correctly identifies the extra key `description`:consttodo: TodoPreview={title: "Clean room",completed: false,description:"123",};// But doesn't pick up if assigned this way:consttodo2: 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.
🔎 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.