Skip to main content

strict-undefined-functions

💼 This rule is enabled in the ✅ recommended config.

Disallows empty return statements in functions annotated as returning undefined.

💭 This rule requires type information.

Rule Details​

void is different from undefined in that undefined is a value and void is the lack of any value. Thus, it is confusing if someone is returning nothing from a function that is annotated as returning undefined. In general, this is indication that either the return type of the function should be changed to void or that undefined should be explicitly returned.

// Bad
function foo(): undefined {
return;
}

// Bad
function foo(): undefined {}

// Good
function foo(): undefined {
return undefined;
}

Options​

This rule is not configurable.

Resources​