Skip to content

Typescript - Breaking changes in 4.9.2 #811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philBrown opened this issue Mar 29, 2023 · 6 comments
Closed

Typescript - Breaking changes in 4.9.2 #811

philBrown opened this issue Mar 29, 2023 · 6 comments

Comments

@philBrown
Copy link

What I wanted to do

Upgrade the Optimizely SDK from 4.9.1 to 4.9.2 without requiring any other code changes.

What I expected to happen

Given it's a patch release, it should just work.

What actually happened

Several breaking changes require updates to consuming code...

  • enums.LOG_LEVEL changes from enum to an object literal. Can no longer use enums.LOG_LEVEL in typings, eg

    Record<MyKey, enums.LOG_LEVEL>

    'enums.LOG_LEVEL' refers to a value, but is being used as a type here. Did you mean 'typeof enums.LOG_LEVEL'?ts(2749)

  • The default export is no longer a namespace requiring the following change

    - import optimizely from '@optimizely/optimizely-sdk';
    + import * as optimizely from '@optimizely/optimizely-sdk';
  • createInstance() now returns Client | null instead of just Client

Steps to reproduce

Change "@optimizely/optimizely-sdk": "4.9.1", to "@optimizely/optimizely-sdk": "4.9.2", in package.json and run tsc.


These changes should have been released as a major version bump, ie v5.0.0.

@philBrown
Copy link
Author

FYI the solution to the first issue is

typeof enums.LOG_LEVEL[keyof typeof enums.LOG_LEVEL]

@opti-jnguyen
Copy link
Contributor

@philBrown - thanks for bringing this to our attention, will look into this.

@opti-jnguyen
Copy link
Contributor

Looks like this was an unintentional breaking change on our end likely introduced in this PR #745 - will have an internal discussion on how we'll address the changes introduced in that PR going into our next release and reply here when we have any updates.

@opti-jnguyen
Copy link
Contributor

Following up on this issue - we are currently prioritizing some features in development, however we plan on accounting for this issue through either a fix or officially addressing the type changes in a future update. In the meantime, please use the workaround for now.

@Tamara-Barum
Copy link

Internal Ticket Created: FSSDK-9569

@raju-opti
Copy link
Contributor

This was an unintentional breaking change that was released as 4.9.2. There were several other releases of v4 after that with the same changes. Recently we released v5 of the sdk. This seems to be a good time to close this issue. Unfortunately, users only updating minor or patch version of v4 will still face the breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants