This rule enforces that an aliased type literal or an interface only has one type of members, eg. only data properties or only functions.
Mixing functions and data properties in the same type is a sign of object-orientation style.
Examples of incorrect code for this rule:
/* eslint functional/no-mixed-type: "error" */
type Foo = {
prop1: string;
prop2: () => string;
};
Examples of correct code for this rule:
/* eslint functional/no-mixed-type: "error" */
type Foo = {
prop1: string;
prop2: number;
};
/* eslint functional/no-mixed-type: "error" */
type Foo = {
prop1: () => string;
prop2: () => () => number;
};
This rule will only check alias type literal declarations and interface declarations. Advanced types will not be checked. For example union and intersection types will not be checked.
This rule accepts an options object of the following type:
{
checkInterfaces: boolean;
checkTypeLiterals: boolean;
}
The default options:
{
checkInterfaces: true,
checkTypeLiterals: true
}
If true, interface declarations will be checked.
If true, aliased type literal declarations will be checked.