-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
enhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin ruleevaluating community engagementwe're looking for community engagement on this issue to show that this problem is widely importantwe're looking for community engagement on this issue to show that this problem is widely importantpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a lookWaiting for team members to take a look
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-*?
Metadata
Metadata
Assignees
Labels
enhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin ruleevaluating community engagementwe're looking for community engagement on this issue to show that this problem is widely importantwe're looking for community engagement on this issue to show that this problem is widely importantpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a lookWaiting for team members to take a look