Require exported object constants to declare an explicit type annotation.
| Property | Value |
|---|---|
| Type | suggestion |
| Fixable | No |
| Recommended | warn |
| Strict | error |
Exported object constants become part of a module's public contract. Requiring an explicit annotation prevents large inferred structural types from leaking through exports and keeps the intended shape readable even when the value is wrapped in Object.freeze(...).
export const StatusMap: Readonly<Record<string, string>> = Object.freeze({
Active: 'active',
Inactive: 'inactive',
});type StatusLookup = Record<string, string>;
const StatusMap: StatusLookup = {
Active: 'active',
};
export { StatusMap };export const StatusMap = Object.freeze({
Active: 'active',
Inactive: 'inactive',
});const StatusMap = {
Active: 'active',
};
export { StatusMap };The rule only applies when the exported const initializer is an object literal or Object.freeze({ ... }). Calls such as Object.freeze() or Object.freeze(...values) are ignored because they do not expose a direct frozen object literal shape.
This rule has no options:
'zero-tolerance/require-exported-object-type': 'error'