@@ -19,6 +19,18 @@ describe('internal wrap()', () => {
1919 expect ( wrap ( num ) ) . toBe ( num ) ;
2020 } ) ;
2121
22+ it ( 'correctly infers types' , ( ) => {
23+ const a = wrap ( 42 ) ;
24+ expect ( a > 40 ) . toBe ( true ) ;
25+
26+ const b = wrap ( '42' ) ;
27+ expect ( b . length ) . toBe ( 2 ) ;
28+
29+ const c = wrap ( ( ) => 42 ) ;
30+ expect ( c ( ) ) . toBe ( 42 ) ;
31+ expect ( c . __sentry_original__ ) . toBeInstanceOf ( Function ) ;
32+ } ) ;
33+
2234 it ( 'should preserve correct function name when accessed' , ( ) => {
2335 const namedFunction = ( ) : number => 1337 ;
2436 expect ( wrap ( namedFunction ) ) . not . toBe ( namedFunction ) ;
@@ -149,7 +161,7 @@ describe('internal wrap()', () => {
149161 } ) ;
150162
151163 it ( 'internal flags shouldnt be enumerable' , ( ) => {
152- const fn = ( ( ) => 1337 ) as WrappedFunction ;
164+ const fn = ( ) => 1337 ;
153165 const wrapped = wrap ( fn ) ;
154166
155167 // Shouldn't show up in iteration
@@ -159,7 +171,7 @@ describe('internal wrap()', () => {
159171 expect ( Object . keys ( wrapped ) ) . toEqual ( expect . not . arrayContaining ( [ '__sentry_wrapped__' ] ) ) ;
160172 // But should be accessible directly
161173 expect ( wrapped . __sentry_original__ ) . toBe ( fn ) ;
162- expect ( fn . __sentry_wrapped__ ) . toBe ( wrapped ) ;
174+ expect ( ( fn as WrappedFunction ) . __sentry_wrapped__ ) . toBe ( wrapped ) ;
163175 } ) ;
164176
165177 it ( 'should only return __sentry_wrapped__ when it is a function' , ( ) => {
0 commit comments