Skip to content

Commit 9c131a2

Browse files
authored
fix: explicit return types and TS6 source compatibility fixes (#1418)
This PR will tighten some type declarations to prepare this repo's upgrade to typescript 6. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Annotation-only and test-mock changes with no security or data-path logic altered. > > **Overview** > Adds **explicit return types** to `createOptions` in the Fastly, Shopify Oxygen, Akamai Edgeworker, and server-edge SDKs (`LDOptions` or `LDOptions & OxygenLDOptions`), so merged options are typed consistently under stricter TypeScript inference. > > For TS 6 / module interop, the **EventProcessor** test mock for `EventSender` now sets `__esModule: true`. In **sortDataSet**, the topological-sort loop uses a **non-null assertion** on `unvisitedItems.values().next().value` when the set is known to be non-empty. > > No intended runtime behavior changes—typing and test compatibility only. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1a0d9dc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 014b59b commit 9c131a2

6 files changed

Lines changed: 6 additions & 5 deletions

File tree

packages/sdk/fastly/src/api/createOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const defaultOptions: LDOptions = {
88
logger: BasicLogger.get(),
99
};
1010

11-
const createOptions = (options: LDOptions) => {
11+
const createOptions = (options: LDOptions): LDOptions => {
1212
const finalOptions = { ...defaultOptions, ...options };
1313

1414
// The Fastly SDK does not poll LaunchDarkly for updates, so a custom baseUri does not make sense. However, we need

packages/sdk/shopify-oxygen/src/utils/createOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const defaultOptions: LDOptions & OxygenLDOptions = {
2626
},
2727
};
2828

29-
export const createOptions = (options: LDOptions & OxygenLDOptions = {}) => {
29+
export const createOptions = (options: LDOptions & OxygenLDOptions = {}): LDOptions & OxygenLDOptions => {
3030
const finalOptions = {
3131
...defaultOptions,
3232
...options,

packages/shared/akamai-edgeworker-sdk/src/utils/createOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const defaultOptions: LDOptions = {
88
logger: BasicLogger.get(),
99
};
1010

11-
export const createOptions = (options: LDOptions) => {
11+
export const createOptions = (options: LDOptions): LDOptions => {
1212
const finalOptions = { ...defaultOptions, ...options };
1313
finalOptions.logger?.debug(`Using LD options: ${JSON.stringify(finalOptions)}`);
1414
return finalOptions;

packages/shared/common/__tests__/internal/events/EventProcessor.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const mockSendEventData = jest.fn();
5050
jest.useFakeTimers();
5151

5252
jest.mock('../../../src/internal/events/EventSender', () => ({
53+
__esModule: true,
5354
default: jest.fn(() => ({
5455
sendEventData: mockSendEventData,
5556
})),

packages/shared/sdk-server-edge/src/api/createOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export const defaultOptions: LDOptions = {
88
logger: BasicLogger.get(),
99
};
1010

11-
const createOptions = (options: LDOptions) => ({ ...defaultOptions, ...options });
11+
const createOptions = (options: LDOptions): LDOptions => ({ ...defaultOptions, ...options });
1212

1313
export default createOptions;

packages/shared/sdk-server/src/store/sortDataSet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function topologicalSort(
5151

5252
while (unvisitedItems.size > 0) {
5353
// Visit the next item, the order we visit doesn't matter.
54-
const key = unvisitedItems.values().next().value;
54+
const key = unvisitedItems.values().next().value!;
5555
visit(key);
5656
}
5757
return sortedItems;

0 commit comments

Comments
 (0)