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/179551806/convert to ts #11

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

ss-eggs
Copy link

@ss-eggs ss-eggs commented Oct 8, 2021

Background

Completed efforts as part of Typescriptify story:
https://www.pivotaltracker.com/n/projects/2533706/stories/179551806

Changes

  • installed typescript and setup config files
  • created fake module declarations for unavailable packages (extra lookup was needed on node-clock package)
  • typescriptify all available functions
  • updated types based on failing tests

@risharma
Copy link
Contributor

@serhalp or @shermam when you've a moment to review this ^

@ss-eggs ss-eggs force-pushed the chore/179551806/convert-to-TS branch from 39ba59c to bf31a32 Compare October 13, 2021 18:42
@serhalp
Copy link

serhalp commented Oct 20, 2021

@ss-eggs could you please take a look at my review of goodeggs/goodeggs-validators#7 and start by making those same changes here? It looks like one of these PRs was copied from the other (instead of the guide: https://goodeggs.atlassian.net/wiki/spaces/ENG/pages/161841475/Porting+from+Flow+to+TypeScript), so there are a lot of the same issues. Thank you!

Copy link

@serhalp serhalp left a comment

Choose a reason for hiding this comment

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

Please see review on goodeggs/goodeggs-validators#7.

Copy link

@serhalp serhalp left a comment

Choose a reason for hiding this comment

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

Partial review: I reviewed everything except the actual source and tests! I'll review the rest a bit later.

@@ -2,3 +2,4 @@
.gitignore
.travis.yml
test/
lib/
Copy link

Choose a reason for hiding this comment

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

If we do this, we'll publish an unusable package that doesn't include the built code, which is the only useful thing to include!

"@goodeggs/tsconfig": "^1.0.0",
"@types/accounting": "^0.4.2",
"@types/jest": "^27.0.2",
"@types/node": "^16.10.2",
Copy link

Choose a reason for hiding this comment

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

You're testing on node 14 so maybe use 14 here?

"@types/node": "^16.10.2",
"@types/sinon": "^10.0.4",
"@types/underscore": "^1.11.3",
"babel-jest": "^27.2.4",
"chai": "^1.10.0",
Copy link

Choose a reason for hiding this comment

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

remove? you switched to jest, so should be unused now

"chai": "^1.10.0",
"jest": "^27.2.4",
"mocha": "~1.x.x",
Copy link

Choose a reason for hiding this comment

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

same here, remove?

"lint:fix": "yarn run lint:fix:es",
"lint:fix:es": "getk run fix-es",
"prepublishOnly": "yarn lint && yarn test && yarn run build",
"test": "jest src/",
Copy link

Choose a reason for hiding this comment

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

This isn't running linting or typechecking in CI.

Suggested change
"test": "jest src/",
"test": "yarn run lint && yarn run typecheck && yarn run test:unit",
"test:unit": "jest",

@@ -0,0 +1,4 @@
declare module 'format-location' {
function formatLocation(location: any, type: string): string;
Copy link

Choose a reason for hiding this comment

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

Consider taking 5 mins to write a correct type here. If it's too complicated, it's ok to leave this as is.

Comment on lines +1 to +3
declare module 'inflect' {
export function ordinalize(arg: string): string;
}
Copy link

Choose a reason for hiding this comment

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

Could you check if we actually need this? Maybe we can remove the function that uses this? I think it's worth taking at least 10 mins to check how we're using this (e.g. in garbanzo).

Copy link
Author

Choose a reason for hiding this comment

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

Library was not created by me. I don't know if methods are being used or not in any of the apps. But I can do a search.. ticket does not specify to look if library or parts of it are being used

Copy link
Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,3183 @@
Arguments:
Copy link

Choose a reason for hiding this comment

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

Please delete this file and add yarn-error.log to .gitignore

@@ -0,0 +1,15 @@
declare module 'node-clock' {
Copy link

Choose a reason for hiding this comment

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

😬

Since node-clock is deprecated, I would be eternally grateful if you could just refactor it away instead of adding this here. You can find hundreds of examples in this PR: https://github.com/goodeggs/garbanzo/pull/7945.

Copy link
Author

Choose a reason for hiding this comment

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

@serhalp the whole package is dependent on this node-clock package functionality.
all formatting filters https://github.com/goodeggs/goodeggs-formatters/blob/chore/179551806/convert-to-TS/src/index.ts#L148 would have to be redone in order to use moment-timeline package to provide same exposed features.
Before I continue the work, I want a sign off from you and @risharma as this was not mentioned in the ticket.

"extends": "./tsconfig.json",
"include": [
"src/**/*.ts",
"types"
Copy link

Choose a reason for hiding this comment

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

I think the correct way to do this is to remove this from here and add this instead:

    "typeRoots": [
      "./node_modules/@types",
      "./types"
    ],

@ss-eggs
Copy link
Author

ss-eggs commented Oct 29, 2021

@serhalp thanks for giving a look. Ticket does not mention refactoring, so I tried not to touch code unless it is impossible add types to certain parts of code.
https://www.pivotaltracker.com/n/projects/2533706/stories/179551806

If refactoring is included - I would refactor the whole library. For now, I will complete whatever was pointed out. In my personal opinion the whole library was written poorly. In the end, I am trying to follow what is mentioned in the ticket.

@missaelpadilla07 missaelpadilla07 self-assigned this Nov 10, 2021
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.

4 participants