export {} declare global { namespace jest { interface Matchers { myMatcher: (received: string) => R } } } function myMatcher(this: jest.MatcherUtils, received: string, expected: string): jest.CustomMatcherResult { const pass = received === expected return { pass, message: (): string => `expected ${received} to be ${expected}`, } } expect.extend({ myMatcher, })