From f81ecc7ff3f1b927b6537220c6cc35391cb9c769 Mon Sep 17 00:00:00 2001 From: Allan Zheng Date: Mon, 12 Jul 2021 18:41:12 -0700 Subject: [PATCH] chore: use inline nullish coalescing instead of helper --- .../aws/typescript/codegen/AddEndpointDiscoveryPlugin.java | 2 +- .../codegen/AddEventStreamHandlingDependency.java | 4 ++-- .../codegen/AddTranscribeStreamingDependency.java | 2 +- packages/smithy-client/src/index.ts | 1 - packages/smithy-client/src/nullish-coalescing.ts | 7 ------- 5 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 packages/smithy-client/src/nullish-coalescing.ts diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java index 0427a78ee3b13..960cae5c68e52 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java @@ -108,7 +108,7 @@ public Map> getRuntimeConfigWriters( case BROWSER: return MapUtils.of( "endpointDiscoveryEnabledProvider", writer -> { - writer.write("() => Promise.resolve(undefined)"); + writer.write("(() => Promise.resolve(undefined))"); } ); case NODE: diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java index 8eae90d83a935..d776f3ed05cc3 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java @@ -107,7 +107,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY); writer.addImport("invalidFunction", "invalidFunction", TypeScriptDependency.INVALID_DEPENDENCY.packageName); - writer.openBlock("() => ({", "})", () -> { + writer.openBlock("(() => ({", "}))", () -> { writer.write("handle: invalidFunction(\"event stream request is not supported in browser.\"),"); }); }); @@ -121,7 +121,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY); writer.addImport("invalidFunction", "invalidFunction", TypeScriptDependency.INVALID_DEPENDENCY.packageName); - writer.openBlock("() => ({", "})", () -> { + writer.openBlock("(() => ({", "}))", () -> { writer.write("handle: invalidFunction(\"event stream request " + "is not supported in ReactNative.\"),"); }); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java index d50435617f217..9a1527f5cca1c 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java @@ -67,7 +67,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE); writer.addImport("eventStreamPayloadHandler", "eventStreamPayloadHandler", AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE.packageName); - writer.write("() => eventStreamPayloadHandler"); + writer.write("(() => eventStreamPayloadHandler)"); }, "requestHandler", writer -> { writer.addDependency(AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE); diff --git a/packages/smithy-client/src/index.ts b/packages/smithy-client/src/index.ts index 7fa70bcac7825..eb390753f4071 100644 --- a/packages/smithy-client/src/index.ts +++ b/packages/smithy-client/src/index.ts @@ -6,7 +6,6 @@ export * from "./extended-encode-uri-component"; export * from "./get-array-if-single-item"; export * from "./get-value-from-text-node"; export * from "./lazy-json"; -export * from "./nullish-coalescing"; export * from "./parse-utils"; export * from "./ser-utils"; export * from "./date-utils"; diff --git a/packages/smithy-client/src/nullish-coalescing.ts b/packages/smithy-client/src/nullish-coalescing.ts deleted file mode 100644 index 4bb50a7eab60e..0000000000000 --- a/packages/smithy-client/src/nullish-coalescing.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Same to nullish coalescing operator(`??`). Used to safe code size of - * JavaScript code. - * - * @internal - */ -export const nullishCoalescing = (a: T | undefined | null, b: T) => (a !== null && a !== void 0 ? a : b);