File tree Expand file tree Collapse file tree 2 files changed +13
-17
lines changed
Expand file tree Collapse file tree 2 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -209,16 +209,6 @@ type JSONValue =
209209 }
210210 | JSONValue [ ] ;
211211
212- type ReadonlyJSONValue =
213- | null
214- | string
215- | number
216- | boolean
217- | {
218- readonly [ K in string ] ?: ReadonlyJSONValue ;
219- }
220- | readonly ReadonlyJSONValue [ ] ;
221-
222212interface JSON {
223213 /**
224214 * Converts a JavaScript Object Notation (JSON) string into an object.
@@ -237,12 +227,8 @@ interface JSON {
237227 * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
238228 */
239229 stringify (
240- value : ReadonlyJSONValue ,
241- replacer ?: (
242- this : ReadonlyJSONValue ,
243- key : string ,
244- value : ReadonlyJSONValue
245- ) => any ,
230+ value : unknown ,
231+ replacer ?: ( this : unknown , key : string , value : unknown ) => any ,
246232 space ?: string | number
247233 ) : string ;
248234 /**
@@ -252,7 +238,7 @@ interface JSON {
252238 * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
253239 */
254240 stringify (
255- value : ReadonlyJSONValue ,
241+ value : unknown ,
256242 replacer ?: ( number | string ) [ ] | null ,
257243 space ?: string | number
258244 ) : string ;
Original file line number Diff line number Diff line change @@ -88,6 +88,16 @@ expectType<{ foo: number; bar: string; baz: boolean }>(
8888 expectType < string > ( JSON . stringify ( readonlyArr ) ) ;
8989 const readonlyObj = { foo : { bar : 1 } } as const ;
9090 expectType < string > ( JSON . stringify ( readonlyObj ) ) ;
91+
92+ // https://github.com/uhyo/better-typescript-lib/issues/5
93+ interface Param {
94+ id : string ;
95+ value : number ;
96+ }
97+ + function foo ( param : Param , readonlyParam : Readonly < Param > ) {
98+ JSON . stringify ( param ) ; // error
99+ JSON . stringify ( readonlyParam ) ;
100+ } ;
91101}
92102
93103// ArrayConstructor
You can’t perform that action at this time.
0 commit comments