Search Terms
Omit Enums, Can I use Enums with Omit utility types
Suggestion
I would like to be able to pass in an enum to the utility type Omit as the second argument.
Use Cases
Currently you can only provide strings when using an Omit I would like to also be able to provide an Enum so I can notify future developers of the keys that are allowed to be Omitted. It would also make defining different types simpler because I can use code completion without having to fully type out the string.
Examples
interface Todo {
title: string;
description: string;
completed: boolean;
}
enum TodoPossibleKeys {
TITLE='title',
DESCRIPTION='description'
}
type TodoPreview = Omit<Todo, TodoPossibleKeys.DESCRIPTION>;
const todo: TodoPreview = {
title: "Clean room",
completed: false,
};
todo;
Checklist
My suggestion meets these guidelines:
Search Terms
Omit Enums, Can I use Enums with Omit utility types
Suggestion
I would like to be able to pass in an enum to the utility type
Omitas the second argument.Use Cases
Currently you can only provide strings when using an
OmitI would like to also be able to provide an Enum so I can notify future developers of the keys that are allowed to be Omitted. It would also make defining different types simpler because I can use code completion without having to fully type out the string.Examples
Checklist
My suggestion meets these guidelines: