Skip to content

typeFunction

Matcher for a function value.

Matchers are applied through assertObjectMatches, where they narrow the corresponding property type.

Type information that already exists in the calling scope is incorporated.

import { assertObjectMatches, typeFunction } from "@kensio/smartass";
const value: unknown = {
callback: () => "done",
};
assertObjectMatches(value, {
callback: typeFunction(),
});
// value is now narrowed to an object with a function callback
// {
// callback: Function;
// }

Source file: src/assert/type-function/type-function.match.ts