-
Notifications
You must be signed in to change notification settings - Fork 99
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
fix: resolve syntax error in old TypeScript versions #1166
fix: resolve syntax error in old TypeScript versions #1166
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.
LGTM 👌🏼. Let's add a changelog item and we'd be good to go.
Let's also link it to a Jira card.
Your snapshot has been generated! 🚀 InstallationYou can install the snapshot through NPM: npm install https://github.com/Instabug/Instabug-React-Native\#snapshot/fix-init-function-error-on-old-node-version or Yarn: yarn add https://github.com/Instabug/Instabug-React-Native\#snapshot/fix-init-function-error-on-old-node-version |
Co-authored-by: Ahmed Mahmoud <68241710+a7medev@users.noreply.github.com>
src/modules/Instabug.ts
Outdated
@@ -64,7 +64,9 @@ export const init = (config: InstabugConfig) => { | |||
captureUnhandledRejections(); | |||
|
|||
// Default networkInterceptionMode to JavaScript | |||
config.networkInterceptionMode ??= NetworkInterceptionMode.javascript; | |||
if (!config.networkInterceptionMode) { |
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.
Let's change this if condition to explicitly check for null
or undefined
instead of !config.networkInterceptionMode
since the enum values will get mapped to integer values with the first enum value being assigned the number 0
so if a user sets the networkInterceptionMode
to the first enum value JavaScript will treat it as false
thus changing the user's intended value to the default one even when it's actually set in the user's code.
In this case the first enum value is javascript
which is the current default so it won't cause bugs, but if we changed the default to be something else users won't be able to set the interception mode to the first enum value as explained above.
if (!config.networkInterceptionMode) { | |
// The `== null` here acts as `=== null or === undefined` | |
if (config.networkInterceptionMode == null) { |
…ode-version' into fix-init-function-error-on-old-node-version
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 👌
Description of the change
Type of change
Related issues
Fixes #1161
Jira ID = INSD-11129
Checklists
Development
Code review