Closed
Description
Search Terms
Omit inexistent keySuggestion
Let's consider next code where we omit inexistent key from interface Todo
:
interface Todo {
title: string;
description: string;
completed: boolean;
}
type TodoPreview = Omit<Todo, 'not_existed_key'>; // currently error is not thrown
Use Cases
Let's imagine that previously interface Todo
had property not_existed_key
and we had variable such as
const todoItem: TodoPreview = {...}
but then not_existed_key
was removed and developer forgot to remove TodoPreview
because it became redundant.
Examples
From my point of view will be better to have more strictly behavior of Omit
.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.