[No QA] [TS migration] Migrate 'Pusher' lib to TypeScript#28116
[No QA] [TS migration] Migrate 'Pusher' lib to TypeScript#28116marcochavezf merged 14 commits intoExpensify:mainfrom
Conversation
src/libs/Pusher/pusher.ts
Outdated
|
|
||
| // Listen for connection errors and log them | ||
| socket.connection.bind('error', (error) => { | ||
| // TODO: check if true |
There was a problem hiding this comment.
Do we need this TODO in prod?
| let data: EventData; | ||
| try { | ||
| data = _.isObject(eventData) ? eventData : JSON.parse(eventData); | ||
| data = isObject(eventData) ? eventData : JSON.parse(eventData); |
There was a problem hiding this comment.
Are we migrating from lodash in a scope of TS migration?
| data = isObject(eventData) ? eventData : JSON.parse(eventData); | |
| data = typeof eventData === 'object' ? eventData : JSON.parse(eventData); |
There was a problem hiding this comment.
Lodash usage is allowed, we are migrating from underscore. And I think usage of lodash here is more safe, because if data will be Array type then typeof data will still be object for example same if data would be a Date
rezkiy37
left a comment
There was a problem hiding this comment.
Left a couple comments.
|
@marcochavezf Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
src/libs/Pusher/pusher.ts
Outdated
| * @param {Object} payload | ||
| */ | ||
| function sendEvent(channelName, eventName, payload) { | ||
| function sendEvent<T>(channelName: string, eventName: PusherEventName, payload: T) { |
There was a problem hiding this comment.
What is the purpose of generic type here? We need to better type payload or at least limit the generic type so it extends Record.
| import Pusher from './types'; | ||
|
|
||
| export default Pusher; | ||
| export default PusherNative satisfies Pusher; |
There was a problem hiding this comment.
From TS guidelines:
Do not use
satisfiesoperator for platform-specific implementations, always define shared types that complies with all variants.
There was a problem hiding this comment.
Hmm , do you have an idea how to type it then? in this case platform specific files exports classes not functions , I dont see better solution for that 🤔
There was a problem hiding this comment.
How about this:
import type Pusher from './types.ts';
import PusherImplementation from 'pusher-js/with-encryption';
const PusherWeb: Pusher = PusherImplementation;
export default PusherWeb;
src/libs/Pusher/pusher.ts
Outdated
| */ | ||
| function registerSocketEventCallback(cb) { | ||
| socketEventCallbacks.push(cb); | ||
| function registerSocketEventCallback<T>(cb: SocketEventCallback<T>) { |
There was a problem hiding this comment.
Same here, why a generic type?
|
@blazejkustra fixed :) |
blazejkustra
left a comment
There was a problem hiding this comment.
TS check is failing, other than that LGTM
|
@marcochavezf are you able to review this? |
marcochavezf
left a comment
There was a problem hiding this comment.
LGTM, just a NAB comment
| * @param {Object} args | ||
| * @param {String} args.appKey | ||
| * @param {String} args.cluster | ||
| * @param {String} args.authEndpoint |
There was a problem hiding this comment.
NAB: Sorry if I'm not up to date with the latest guidelines, but shouldn't we add a type for args if we already defined the types in JSDoc?
There was a problem hiding this comment.
No, for typescript migrations we are removing all JSDocs types we are leaving only params descriptions
|
@marcochavezf Are you able to do PR reviewer checklist or assign someone to do that? |
Reviewer Checklist
Screenshots/VideosWebMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Performance Comparison Report 📊Significant Changes To Duration
Show details
Meaningless Changes To DurationShow entries
Show details
|
|
@Expensify/mobile-deployers 📣 Please look into this performance regression as it's a deploy blocker. |
|
🚀 Deployed to staging by https://github.com/marcochavezf in version: 1.3.84-0 🚀
|
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.84-10 🚀
|
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.84-10 🚀
|
|
🚀 Deployed to staging by https://github.com/marcochavezf in version: 1.3.85-0 🚀
|
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.85-4 🚀
|
Details
Fixed Issues
$ 24896
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android