Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-clouds-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/smithy-client": patch
---

fix new operator typing for LazyJsonString
16 changes: 11 additions & 5 deletions packages/smithy-client/src/lazy-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export type AutomaticJsonStringConversion = Parameters<typeof JSON.stringify>[0]
*
*/
export interface LazyJsonString extends String {
new (s: string): typeof LazyJsonString;

/**
* @returns the JSON parsing of the string value.
*/
Expand All @@ -40,7 +38,7 @@ export interface LazyJsonString extends String {
* This current implementation may look strange, but is necessary to preserve the interface and
* behavior of extending the String class.
*/
export function LazyJsonString(val: string): void {
export const LazyJsonString = function LazyJsonString(val: string): void {
const str = Object.assign(new String(val), {
deserializeJSON() {
return JSON.parse(String(val));
Expand All @@ -56,7 +54,15 @@ export function LazyJsonString(val: string): void {
});

return str as never;
}
} as any as {
new (s: string): LazyJsonString;
(s: string): LazyJsonString;
from(s: any): LazyJsonString;
/**
* @deprecated use #from.
*/
fromObject(s: any): LazyJsonString;
};

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

/**
* @deprecated use from.
* @deprecated use #from.
*/
LazyJsonString.fromObject = LazyJsonString.from;
Loading