@@ -17,8 +17,6 @@ export type AutomaticJsonStringConversion = Parameters<typeof JSON.stringify>[0]
17
17
*
18
18
*/
19
19
export interface LazyJsonString extends String {
20
- new ( s : string ) : typeof LazyJsonString ;
21
-
22
20
/**
23
21
* @returns the JSON parsing of the string value.
24
22
*/
@@ -40,7 +38,7 @@ export interface LazyJsonString extends String {
40
38
* This current implementation may look strange, but is necessary to preserve the interface and
41
39
* behavior of extending the String class.
42
40
*/
43
- export function LazyJsonString ( val : string ) : void {
41
+ export const LazyJsonString = function LazyJsonString ( val : string ) : void {
44
42
const str = Object . assign ( new String ( val ) , {
45
43
deserializeJSON ( ) {
46
44
return JSON . parse ( String ( val ) ) ;
@@ -56,7 +54,15 @@ export function LazyJsonString(val: string): void {
56
54
} ) ;
57
55
58
56
return str as never ;
59
- }
57
+ } as any as {
58
+ new ( s : string ) : LazyJsonString ;
59
+ ( s : string ) : LazyJsonString ;
60
+ from ( s : any ) : LazyJsonString ;
61
+ /**
62
+ * @deprecated use #from.
63
+ */
64
+ fromObject ( s : any ) : LazyJsonString ;
65
+ } ;
60
66
61
67
LazyJsonString . from = ( object : any ) : LazyJsonString => {
62
68
if ( object && typeof object === "object" && ( object instanceof LazyJsonString || "deserializeJSON" in object ) ) {
@@ -68,6 +74,6 @@ LazyJsonString.from = (object: any): LazyJsonString => {
68
74
} ;
69
75
70
76
/**
71
- * @deprecated use from.
77
+ * @deprecated use # from.
72
78
*/
73
79
LazyJsonString . fromObject = LazyJsonString . from ;
0 commit comments