-
Notifications
You must be signed in to change notification settings - Fork 83
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
refactor: Replaced explicit typings with auto generated ones #745
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good so far. Requested a few more changes
EventDispatcher, | ||
DatafileOptions, | ||
SDKOptions, | ||
OptimizelyOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SDKOptions and OptimizelyOptions are not needed to be exposed. Config is enough for external usage
eventTags: EventTags; | ||
logEvent: Event; | ||
} | ||
|
||
/** | ||
* Entry level Config Entities | ||
*/ | ||
export interface SDKOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you compare it with Config
and remove it if not needed. this looks redundant and might not be needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config and SDKOptions shares most of the same variables except for:
Config:
- Extra
jsonSchemaValidator
variable in interface. - Instead of using
LogLevel | string
, uses union type on all LOG_LEVEL enums.
SDKOptions contains:
- Extra
eventMaxQueueSize
variable in interface. - Extra
isValidInstance
variable in interface.
We should consider having a base interface both Config
and SDKOptions
extend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for pointing these out. WE are consolidating these two types in to one because Config
was exposed from the explicit typings while SDKOptions
was being used in the actual code. We need to use one of those now because we are removing the explicit types. We will keep Config
and remove SDKOptions
because thats what was being exposed to typescript users. I have requested @ozayr-zaviar to add the missing variables mentioned in your comments.
- fixed some lint warnings - Added changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT! Great work @ozayr-zaviar
@opti-jnguyen It will be great if we can get your review on this whenever you find some time. |
This reverts commit 90e4149.
datafile?: string, | ||
logger: LoggerFacade, | ||
// TODO[OASIS-6649]: Don't use object type | ||
// eslint-disable-next-line @typescript-eslint/ban-types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were these comments left here intentionally?
Saw more instances of this comment left around but don't see the associated ticket #6649 in the OASIS JIRA Issues list for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://optimizely.atlassian.net/browse/OASIS-6649
This should be moved to the tech debt epic. This is something thats tricky to resolve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ozayr-zaviar I have a few more change request.
Config
should also export a jsonSchemaValidator just likeOptimizelyOptions
isValidInstance
is not logically needed onConfig
. We were just usingconfig
to hold this value and pass on toOptimizely
constructor instead of storing it in to a local variable in the entry point. Please fix this.- Update copyright headers wherever applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for cleaning up the typings mess. Great work @ozayr-zaviar
|
||
export function setLogLevel(level: enums.LOG_LEVEL | string): void; | ||
|
||
export function createInstance(config: Config): Client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change as it can now be Client | null
Summary
This SDK was originally javascript only. We had to add explicit typings in
lib/index.d.ts
to support typescript users. Now that it has been converted to typescript, we can safely removelib/index.d.ts
and autogenerate typings. This PR does exactly that. We also encountered some discrepancies with existing typings so we fixed those too.Test plan