@@ -3,7 +3,7 @@ import { doNotExecute, Equal, Expect } from "./utils";
33doNotExecute ( ( ) => {
44 const result = JSON . stringify ( { } ) ;
55
6- type tests = [ Expect < Equal < typeof result , string > > ] ;
6+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
77} ) ;
88
99doNotExecute ( ( ) => {
@@ -23,7 +23,7 @@ doNotExecute(() => {
2323 let toBeStringified : { } | null = Math . random ( ) > 0.5 ? { } : null ;
2424 const result = JSON . stringify ( toBeStringified ) ;
2525
26- type tests = [ Expect < Equal < typeof result , string > > ] ;
26+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
2727} ) ;
2828
2929doNotExecute ( ( ) => {
@@ -38,7 +38,19 @@ doNotExecute(() => {
3838 // create a something that is a function
3939 const result = JSON . stringify ( function ( ) { } ) ;
4040
41- type tests = [ Expect < Equal < typeof result , undefined > > ] ;
41+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
42+ } ) ;
43+
44+ doNotExecute ( ( ) => {
45+ function hello ( ) { }
46+ function addToJSONtoFunction ( func : any ) {
47+ func . toJSON = ( ) => "foo" ;
48+ }
49+ addToJSONtoFunction ( hello ) ;
50+
51+ const result = JSON . stringify ( hello ) ;
52+
53+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
4254} ) ;
4355
4456doNotExecute ( ( ) => {
@@ -52,7 +64,7 @@ doNotExecute(() => {
5264 // create a something that is a function
5365 const result = JSON . stringify ( function ( hello : any , world : any ) { } ) ;
5466
55- type tests = [ Expect < Equal < typeof result , undefined > > ] ;
67+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
5668} ) ;
5769
5870doNotExecute ( ( ) => {
@@ -74,7 +86,7 @@ doNotExecute(() => {
7486 // create a something that is a Date object
7587 const result = JSON . stringify ( new Date ( ) ) ;
7688
77- type tests = [ Expect < Equal < typeof result , string > > ] ;
89+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
7890} ) ;
7991
8092doNotExecute ( ( ) => {
@@ -115,7 +127,7 @@ doNotExecute(() => {
115127 } ;
116128 const result = JSON . stringify ( objWithToJSON ) ;
117129
118- type tests = [ Expect < Equal < typeof result , undefined > > ] ;
130+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
119131} ) ;
120132
121133doNotExecute ( ( ) => {
@@ -125,7 +137,7 @@ doNotExecute(() => {
125137 } ;
126138 const result = JSON . stringify ( objWithToJSON ) ;
127139
128- type tests = [ Expect < Equal < typeof result , string > > ] ;
140+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
129141} ) ;
130142
131143doNotExecute ( ( ) => {
@@ -135,7 +147,7 @@ doNotExecute(() => {
135147 } ;
136148 const result = JSON . stringify ( objWithToJSON ) ;
137149
138- type tests = [ Expect < Equal < typeof result , undefined > > ] ;
150+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
139151} ) ;
140152
141153doNotExecute ( ( ) => {
@@ -145,7 +157,7 @@ doNotExecute(() => {
145157 functionWithToJSON . toJSON = ( ) => "foo" ;
146158 const result = JSON . stringify ( functionWithToJSON ) ;
147159
148- type tests = [ Expect < Equal < typeof result , string > > ] ;
160+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
149161} ) ;
150162
151163doNotExecute ( ( ) => {
@@ -163,5 +175,5 @@ doNotExecute(() => {
163175 // Date has a toJSON method
164176 const result = JSON . stringify ( new Date ( ) ) ;
165177
166- type tests = [ Expect < Equal < typeof result , string > > ] ;
178+ type tests = [ Expect < Equal < typeof result , string | undefined > > ] ;
167179} ) ;
0 commit comments