Skip to content

Conversation

@iida-hayato
Copy link
Contributor

@iida-hayato iida-hayato commented Jan 8, 2020

  • convert to typescript code
    • serve/hosting.ts
    • hosting/initMiddleware
    • hosting/normalizedHostingConfigs
    • hosting/implicitInit
  • check npm t
  • check npm run lint
  • local test

@iida-hayato iida-hayato changed the title [Refactoring] convert hosting/*.js to typescript code [WIP][Refactoring] convert hosting/*.js to typescript code Jan 8, 2020
@googlebot googlebot added the cla: yes Manual indication that this has passed CLA. label Jan 8, 2020
@coveralls
Copy link

coveralls commented Jan 8, 2020

Coverage Status

Coverage increased (+0.01%) to 65.581% when pulling 7c3def0 on iida-hayato:ts-hosting into 9ca80cf on firebase:master.

import * as _ from "lodash";

function _filterOnly(configs, onlyString) {
type HostingConfig = { site: string; target: string };
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to use a type here but use an interface for TemplateServerResponse?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's no reason.
it seems more better to interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

please prefer interfaces to types. Maybe that's something I could enforce with the linter in the future...

@samtstern samtstern requested a review from bkendall January 8, 2020 21:13
@samtstern
Copy link
Contributor

@iida-hayato thanks for doing this! I left some small comments, hopefully @bkendall can do a review as well.

@iida-hayato
Copy link
Contributor Author

There seems to be a better name for the added types.
such as

  • TemplateServerResponce
  • HostingConfig
  • ApplicationHandler

But i have no idea . 🤔

Copy link
Contributor

@bkendall bkendall left a comment

Choose a reason for hiding this comment

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

Alright, you prompted me to write up a script that should help identify easy bits to clean up while rewriting this code. If you would do the following, it would be appreciated:

  1. Make sure your local master branch is up to date and sync this branch with it.
  2. Run npm run lint:changed-files - it should print 28 "problems" (which are lint warnings) that should be addressed. Most of it will be fairly trivial, but worth addressing.

One of the tricker warnings to get rid of in some of the files will be @typescript-eslint/no-explicit-any, especially when it comes to req, res, and next. If you get stuck, silence that warning by adding a comment to the end of the line: // eslint-disable-line @typescript-eslint/no-explicit-any (if the formatter complains, you can use // eslint-disable-next-line @typescript-eslint/no-explicit-any above it instead).

/**
* generate template server responce
* @param options
* @return {Promise<{js: string, json: string}>}
Copy link
Contributor

Choose a reason for hiding this comment

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

Specifying return types in a typescript file is redundant. Please just include a brief written description of what is returned. e.g.:

Suggested change
* @return {Promise<{js: string, json: string}>}
* @return the initialization configuration.

import * as _ from "lodash";

function _filterOnly(configs, onlyString) {
type HostingConfig = { site: string; target: string };
Copy link
Contributor

Choose a reason for hiding this comment

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

please prefer interfaces to types. Maybe that's something I could enforce with the linter in the future...

module.exports = function(options) {
/**
* @param options
* @return {any[] | HostingConfig[]}
Copy link
Contributor

Choose a reason for hiding this comment

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

lint --fix adds this return type? I will dig into that as it shouldn't in TS...

@iida-hayato
Copy link
Contributor Author

Generated JSDocs seems useless, so I erased and rewrite JSDoc comments.
Tell me if I wrote wrong comments.

@bkendall
Copy link
Contributor

FYI - I've still got this on my radar, but dedicating the time to make sure I can go through it is a little tricky. I'm hoping to get back to you today or tomorrow. Thanks for the PR and your patience.

@iida-hayato iida-hayato changed the title [WIP][Refactoring] convert hosting/*.js to typescript code [Refactoring] convert hosting/*.js to typescript code Jan 17, 2020
@iida-hayato
Copy link
Contributor Author

@bkendall

All right.
today, I fixed code as I can.

If this still difficult to merge, you can close it.

or, Is there any other code that preferentially converts to typescript?
I can help that.

@bkendall
Copy link
Contributor

Thanks for keeping on top of this. I've been horrible at actually getting back to you on this and I apologize for that - things have been rather busy for me as of late as other things have taken priority. I appreciate the PR and promise I haven't lost track of it!

@iida-hayato
Copy link
Contributor Author

iida-hayato commented Feb 3, 2020

Because base's hosting.js has been changed,
It would be better to close this PR and recreate a new PR 🤔

@bkendall
Copy link
Contributor

bkendall commented Feb 3, 2020

I've been super super busy, so I haven't gotten time to sit down on this, but I was going to manually resolve the conflicts and merge this. If you can manage to resolve the conflicts yourself in the next few days, I will promise to re-review by the end of the week. Otherwise, it may be next week when I get a chance to wrap this up.

@bkendall
Copy link
Contributor

bkendall commented Feb 3, 2020

(seriously, thank you for your patience and I'm sorry I've been slooww)

@bkendall
Copy link
Contributor

🎶 I'm horrible, it's true 🎶

(to the tune of You're Beautiful)

I'm looking at this right now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Manual indication that this has passed CLA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants