optimizely/javascript-sdk

[ENHANCEMENT] Provide TypeScript types for feature experimentation API responses

mcalthrop opened this issue · 3 comments

Description

It would be incredibly useful to use TS data types returned from the API, ie, the ones listed here:
https://docs.developers.optimizely.com/feature-experimentation/reference/

Specifically, I'm interested in the types for this endpoint:
https://docs.developers.optimizely.com/feature-experimentation/reference/list_flags

NOTE: these might already exist, but after searching for quite a while, I have not yet been able to find them.

Benefits

At the moment, when calling the API via TypeScript, I will have to define my own types to process the response, which is a brittle solution.

Having access to the actual types returned would be far more robust.

Detail

Suggest exposing the types via an NPM library, or adding them to to the existing @optimizely/optimizely-sdk library.

Examples

No response

Risks/Downsides

No response

Hey @mcalthrop , we will have an initial discussion on this on next Monday.

Hi @mcalthrop,

I think I understand your request here, but let me make sure.

image

When I run the /list_flags in the above screenshot, you're requesting a .d.ts file (or some other TypeScript friendly way) that would create a type-safe FlagsList class with fields like count: number, created_by_user_id: string, outlier_filtering_enabled: boolean, items: Flags[], etc.

If I have this correct, I think I need to direct you to the Customer Feedback site to submit your (excellent) idea over there for the Product team to review. The JS SDK itself does not leverage the REST API of the Optimizely Experimentation platform.

🤔 We probably have to (thinking out loud here) publish a separate @types package to npm and CI/CD our way to ensuring it reflects any API changes. This might also be something that other strongly typed langs might want

If I'm mistaken with your ask, please re-open this Issue and straighten out my understanding😁

Hi @mcalthrop,

I think I understand your request here, but let me make sure.

When I run the /list_flags in the above screenshot, you're requesting a .d.ts file (or some other TypeScript friendly way) that would create a type-safe FlagsList class with fields like count: number, created_by_user_id: string, outlier_filtering_enabled: boolean, items: Flags[], etc.

Yes, that is correct @mikechu-optimizely. Thank you for clarifying.

If I have this correct, I think I need to direct you to the Customer Feedback site to submit your (excellent) idea over there for the Product team to review. The JS SDK itself does not leverage the REST API of the Optimizely Experimentation platform.

I don't have (or require) an Optimizely World account.

🤔 We probably have to (thinking out loud here) publish a separate @types package to npm and CI/CD our way to ensuring it reflects any API changes. This might also be something that other strongly typed langs might want

Yes, I'd expect that's the right route, and other languages would want as well. I'm surprised it isn't already available.

If I'm mistaken with your ask, please re-open this Issue and straighten out my understanding😁

Nope, all good thanks!