Open
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/no-empty-object-type/
Description
I suggest that the no-empty-object-type
rule also disallows {}
generated by type transformations.
For example, using Omit<V,K>
on a type that is nullable will unintentionally create a {}
type.
type NullableData = null | { name: string; num: number };
type ITS_EMPTY_OBJECT_TYPE = Omit<NullableData, 'name'>; // '{}'
Fail
type Data = { name: string; num: number };
type NullableData = null | Data;
function doSomething<T extends Omit<NullableData, 'name'> // lint error
>(param: T) { }
type Unexpected = Omit<NullableData, 'name'>; // lint error
Pass
type Data = { name: string; num: number };
function doSomething<T extends Omit<Data, 'name'>>(param: T) { }
type Expected = Omit<Data, 'name'>;
Additional Info
Perhaps it would be appropriate to handle this in no-unsafe-*?