Skip to content
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

chore: convert some server files into TypeScript #757

Merged
merged 20 commits into from
Oct 7, 2019

Conversation

Naturalclar
Copy link
Member

@Naturalclar Naturalclar commented Sep 29, 2019

Summary:

This PR is part of #683
Converted some of server related files into TypeScript

Test Plan:

  • yarn
  • yarn lint
  • yarn flow-check

packages/cli/package.json Show resolved Hide resolved
packages/cli/src/commands/server/launchDebugger.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/server/launchDefaultBrowser.ts Outdated Show resolved Hide resolved
@@ -9,18 +9,22 @@

import ws from 'ws';
import {logger} from '@react-native-community/cli-tools';
import {Server as HttpServer} from 'http';
import {Server as HttpsServer} from 'https';
import WebSocket from 'ws';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ws is imported twice, can we do it one?

@thymikee
Copy link
Member

cc @Esemesek

@Naturalclar
Copy link
Member Author

Thanks for the feedback! I've made some changes to improve with typings and removed some ts-ignores.

Copy link
Member

@grabbou grabbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see another PR towards full TypeScript migration! Left some feedback as well.

@Naturalclar Naturalclar requested a review from grabbou October 2, 2019 06:39
@@ -46,8 +45,14 @@ function getChromeAppName(): string {
}
}

function launchChrome(url: string) {
return open(url, {app: [getChromeAppName()], wait: true});
async function launchChrome(url: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this whole change. It introduces a regression, since we don't want to catch this exception here

| 'emacsclient'
| 'rmate'
| 'mate'
| 'mine';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, we don't have resources to maintain this list. Please use just string

clientSocket.onerror = clientSocketCloseHandler;
clientSocket.onclose = clientSocketCloseHandler;
clientSocket.onmessage = ({data}) => send(debuggerSocket, data);
if (clientSocket) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we assume connection is defined on line 52, let's skip this check if possible

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the type of connection in this function argument and removed this check

clientSocket.onmessage = null;
clientSocket.onerror = () => {};
clientSocket.onclose = () => {};
clientSocket.onmessage = () => {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these reassignments are necessary, because they're overwritten right after. It only makes sense to null them when clientSocket.close throws for some reason and we try to recover – the handlers could leak memory because clientSocket would hold them. I'm not sure if that happens, didn't have time to go through this deeply.

For now, let's revert to what was here before and ts-ignore it with a todo comment to rewrite, once we migrate to newer version of ws library.

@Naturalclar Naturalclar requested a review from thymikee October 7, 2019 08:37
@thymikee thymikee changed the title Converted some server files into TypeScript chore: convert some server files into TypeScript Oct 7, 2019
@thymikee thymikee merged commit 4cfc27a into react-native-community:master Oct 7, 2019
@thymikee
Copy link
Member

thymikee commented Oct 7, 2019

Thank you!

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

Successfully merging this pull request may close these issues.

3 participants