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 =
209
209
}
210
210
| JSONValue [ ] ;
211
211
212
- type ReadonlyJSONValue =
213
- | null
214
- | string
215
- | number
216
- | boolean
217
- | {
218
- readonly [ K in string ] ?: ReadonlyJSONValue ;
219
- }
220
- | readonly ReadonlyJSONValue [ ] ;
221
-
222
212
interface JSON {
223
213
/**
224
214
* Converts a JavaScript Object Notation (JSON) string into an object.
@@ -237,12 +227,8 @@ interface JSON {
237
227
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
238
228
*/
239
229
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 ,
246
232
space ?: string | number
247
233
) : string ;
248
234
/**
@@ -252,7 +238,7 @@ interface JSON {
252
238
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
253
239
*/
254
240
stringify (
255
- value : ReadonlyJSONValue ,
241
+ value : unknown ,
256
242
replacer ?: ( number | string ) [ ] | null ,
257
243
space ?: string | number
258
244
) : string ;
Original file line number Diff line number Diff line change @@ -88,6 +88,16 @@ expectType<{ foo: number; bar: string; baz: boolean }>(
88
88
expectType < string > ( JSON . stringify ( readonlyArr ) ) ;
89
89
const readonlyObj = { foo : { bar : 1 } } as const ;
90
90
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
+ } ;
91
101
}
92
102
93
103
// ArrayConstructor
You can’t perform that action at this time.
0 commit comments