Skip to main content

complete/prefer-unknown-type-annotations

💼 This rule is enabled in the ✅ recommended config.

📝 Require variable type annotations over as unknown assertions.

🔧 This rule is automatically fixable by the --fix CLI option.

Require variable type annotations over as unknown assertions.

Rule Details

// Bad
const foo = JSON.parse(fooContents) as unknown;

// Good
const foo: unknown = JSON.parse(fooContents);

Options

This rule is not configurable.

Resources