import type * as ts from 'typescript' ; import { CustomFunction } from '../../matcher/matcher' ; import { assertTypeArgumentPresence } from './assert-type-argument-presence' ; function isDeclarationWithName ( declaration , declarationName ) { return declaration . name ?. getText ( ) === declarationName ; } export function customFunctionWithTypeArgument ( sourceName , declarationName , run ) { return { sourceDts : sourceName , sourceUrl : `../${ sourceName }` , isHandledFunction ( node , declaration ) { return isDeclarationWithName ( declaration , declarationName ) ; } , run ( node ) { assertTypeArgumentPresence ( node ) ; const [ nodeToMock ] = node . typeArguments ; return run ( node , nodeToMock ) ; } , } ; }