Skip to contentSlop Block

no-unknown-parameters

Error

Use concrete parameter types. Avoid unknown, dynamic and Object. TypeScript allows cause and type-predicate parameters; Dart allows operator ==.

function handle(input: unknown) {}Do not accept unknown as a parameter type
const handle = (input: unknown | string) => input;Do not accept unknown as a parameter type
class Store {	public set(key: string, value?: unknown) {}Do not accept unknown as a parameter type}
// ast-grep-ignore: no-unknown-parameters-typescript

How to fix

Parse the input where it enters the program and pass the parsed type along.

A parameter can be unknown if it is named cause or belongs to an assertion function or a function with a type predicate (value is User).