optimizely/javascript-sdk

Typescript - Breaking changes in 4.9.2

philBrown opened this issue · 6 comments

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.

FYI the solution to the first issue is

typeof enums.LOG_LEVEL[keyof typeof enums.LOG_LEVEL]

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

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.

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.

Internal Ticket Created: FSSDK-9569

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.