import { instance , mock , when , It } from '../src' ; it ( 'type safety' , ( ) => { function mockSafety ( ) { const fn = mock < ( ) => void > ( ) ; fn ( 23 ) ; const obj = mock < { foo : ( ) => void ; } > ( ) ; obj . foo ( 23 ) ; obj . bar ( ) ; } function whenSafety ( ) { const fn = mock < ( ) => void > ( ) ; const fnp = mock < ( ) => Promise < void > > ( ) ; when ( fn ( ) ) . thenReturn ( 23 ) ; when ( fn ( ) ) . thenResolve ; when ( fn ( ) ) . thenThrow ( 23 ) ; when ( fnp ( ) ) . thenReturn ( 23 ) ; when ( fnp ( ) ) . thenResolve ( 23 ) ; when ( fnp ( ) ) . thenReject ( 23 ) ; when ( fnp ( ) ) . thenThrow ; const fnany = mock < ( ) => any > ( ) ; when ( fnany ( ) ) . thenReturn ( 23 ) ; } function instanceSafety ( ) { const fn = mock < ( ) => void > ( ) ; instance ( fn ) ( 23 ) ; const x = instance ( fn ) ( ) ; const obj = mock < { foo : ( ) => void ; } > ( ) ; instance ( obj ) . foo ( 23 ) ; instance ( obj ) . bar ( ) ; const y = instance ( obj ) . foo ( ) ; } function matcherSafety ( ) { const number = ( x ) => x ; number ( It . isAny ( ) ) ; number ( It . isString ( ) ) ; const nestedObject = ( x ) => x ; nestedObject ( It . isObject ( ) ) ; nestedObject ( It . isObject ( { foo : { bar : 23 } } ) ) ; nestedObject ( It . isObject ( { foo : { bar : 'boo' } } ) ) ; nestedObject ( It . isObject ( { foo : It . isObject ( ) } ) ) ; const numberArray = ( x ) => x ; numberArray ( It . isArray ( ) ) ; numberArray ( It . isArray ( [ 1 , 2 , 3 ] ) ) ; numberArray ( It . isArray ( [ It . isNumber ( ) ] ) ) ; numberArray ( It . isArray ( [ 'a' ] ) ) ; numberArray ( It . isArray ( [ It . isString ( ) ] ) ) ; const object = ( x ) => x ; object ( It . isObject ( { foo : It . isNumber ( ) } ) ) ; object ( It . isObject ( { foo : It . isString ( ) } ) ) ; const objectWithArrays = ( x ) => x ; objectWithArrays ( It . isObject ( { foo : { bar : It . isArray ( [ It . isNumber ( ) ] ) , } , } ) ) ; objectWithArrays ( It . isObject ( { foo : { bar : It . isArray ( [ It . isString ( ) ] ) , } , } ) ) ; const string = ( x ) => string ; const captureMatcher = It . willCapture < number > ( ) ; captureMatcher . matches ( 'aaa' ) ; number ( captureMatcher . value ) ; string ( captureMatcher . value ! ) ; } } ) ;