explicit-module-boundary-types
Configuration
Require explicit return and argument types on exported functions' and classes' public class methods.
Rule Details
Code that is part of a module's public surface — exported functions, exported class methods, default-exported expressions — is consumed by other modules whose authors can't see your implementation. Annotating the parameter and return types at that boundary documents the contract, lets editors offer accurate help, and prevents downstream callers from accidentally relying on the inferred type of an internal helper.
This rule reports any exported function, exported class method, or value reachable via an export reference that omits its parameter types or return type.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule accepts an options object with the following properties:
allowArgumentsExplicitlyTypedAsAny(defaultfalse): permit parameters explicitly annotated asany.allowDirectConstAssertionInArrowFunctions(defaulttrue): skip the return-type check on body-less arrow functions whose result isas const(optionally followed bysatisfies T). Parameters still must be typed.allowedNames(default[]): list of function or method names to skip entirely (both return type and parameters).allowHigherOrderFunctions(defaulttrue): skip the return-type check on functions that immediately return another function expression, as long as the inner function has a return type.allowOverloadFunctions(defaultfalse): skip the return-type check on the implementation of an overloaded function/method.allowTypedFunctionExpressions(defaulttrue): skip the return-type check on function expressions whose surrounding context already supplies a type (variable annotation, type assertion, typed property, JSX attribute, function argument, …).
allowArgumentsExplicitlyTypedAsAny
Examples of incorrect code with { "allowArgumentsExplicitlyTypedAsAny": false } (the default):
Examples of correct code with { "allowArgumentsExplicitlyTypedAsAny": true }:
allowDirectConstAssertionInArrowFunctions
Examples of correct code with the default { "allowDirectConstAssertionInArrowFunctions": true }:
allowedNames
Examples of correct code with { "allowedNames": ["func1"] }:
allowHigherOrderFunctions
Examples of correct code with the default { "allowHigherOrderFunctions": true }:
allowOverloadFunctions
Examples of correct code with { "allowOverloadFunctions": true }:
allowTypedFunctionExpressions
Examples of correct code with the default { "allowTypedFunctionExpressions": true }: