Skip to content

Commit 7f17426

Browse files
authored
type-fix for LazyJsonString call interface (#1476)
1 parent e27d42d commit 7f17426

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.changeset/khaki-clouds-tease.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/smithy-client": patch
3+
---
4+
5+
fix new operator typing for LazyJsonString

packages/smithy-client/src/lazy-json.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export type AutomaticJsonStringConversion = Parameters<typeof JSON.stringify>[0]
1717
*
1818
*/
1919
export interface LazyJsonString extends String {
20-
new (s: string): typeof LazyJsonString;
21-
2220
/**
2321
* @returns the JSON parsing of the string value.
2422
*/
@@ -40,7 +38,7 @@ export interface LazyJsonString extends String {
4038
* This current implementation may look strange, but is necessary to preserve the interface and
4139
* behavior of extending the String class.
4240
*/
43-
export function LazyJsonString(val: string): void {
41+
export const LazyJsonString = function LazyJsonString(val: string): void {
4442
const str = Object.assign(new String(val), {
4543
deserializeJSON() {
4644
return JSON.parse(String(val));
@@ -56,7 +54,15 @@ export function LazyJsonString(val: string): void {
5654
});
5755

5856
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+
};
6066

6167
LazyJsonString.from = (object: any): LazyJsonString => {
6268
if (object && typeof object === "object" && (object instanceof LazyJsonString || "deserializeJSON" in object)) {
@@ -68,6 +74,6 @@ LazyJsonString.from = (object: any): LazyJsonString => {
6874
};
6975

7076
/**
71-
* @deprecated use from.
77+
* @deprecated use #from.
7278
*/
7379
LazyJsonString.fromObject = LazyJsonString.from;

0 commit comments

Comments
 (0)