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

Convert project to TypeScript #52

Merged
merged 203 commits into from
Nov 1, 2023
Merged

Convert project to TypeScript #52

merged 203 commits into from
Nov 1, 2023

Conversation

ComradeVanti
Copy link
Collaborator

This is an initial attempt to transition the project to TypeScript.

The tests pass, but obviously there would need to be an additional compile step somewhere when building the project for production.

This conversion has exposed a lot of potential undefined and other errors. I have highlighted these with TODO comments.

Hope to get some feedback on this.

@ComradeVanti
Copy link
Collaborator Author

Two more notes on this:

  1. I know, no one asked for this, I just felt kind of inspired. Also I want to maybe add more to this project and I would love to do that with TypeScript.
  2. I attempted to change the actual logic as little as possible. I only introduced types.

@favoyang
Copy link
Member

Wow, this is really cool. I appreciate TypeScript for its debugging ease. There's a lot of work ahead, and I admire your passion and efforts. Thanks for that. I might have more feedback to share over the weekend.

Currently, our CI is encountering issues due to an incompatible Node version. The project requires Node v14, as specified in the .nvmrc file, while it seems you are using Node v18. I hope we can support v14 to support a smoother upgrade for our existing users. However, if it's necessary to work with the latest LTS, I'm open to that too.

@ComradeVanti
Copy link
Collaborator Author

Oops, didn't notice the node change. I might take a look to see if I can rework it for v14 if you thinks that's better. Let me know what you think.

@favoyang
Copy link
Member

My apologies for the incorrect message. The Node version isn't the problem, the PR works with Node v14. It's actually a compatibility issue due to a recent npm that breaks the CI. Please rebase the master branch.

When attempting to fix eslint rules in file, the following error appeared

```Error: "prettier/vue" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21```

Reading the linked changelog, it seemed the fix was to simply only use the prettier/recommended extension. Simplified eslintrc to reflect this.
@ComradeVanti
Copy link
Collaborator Author

Just did a rebase to include 23f43fd. Hope that is what you meant

When attempting to fix eslint rules in file, the following error appeared

```Error: "prettier/vue" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21```

Reading the linked changelog, it seemed the fix was to simply only use the prettier/recommended extension. Simplified eslintrc to reflect this.
@favoyang
Copy link
Member

Yes, the CI is passed now.

@ComradeVanti
Copy link
Collaborator Author

Cool. Do you need any more changes?

@favoyang
Copy link
Member

No, thanks. Perhaps I will give more feedback on the weekend.

@ComradeVanti
Copy link
Collaborator Author

ComradeVanti commented Oct 17, 2023

Do you mind if I do a few more refactors on this PR or would you rather wait on that?

@favoyang
Copy link
Member

Sure you can do more refactors.

@ComradeVanti
Copy link
Collaborator Author

Cool, I'll try to keep it at refactors only, or at maximum add more tests. But no new features for now. Ulitmately I'd like to add #49 ;)

Eslint was complaining about various keywords being reserved and was unerlining them. Fixed by installing `typescript-eslint` according to [this guide](https://typescript-eslint.io/getting-started)
reformat and clean-up using new eslint config
Bumped because >=2 includes typings and seemingly no other breaking changes
On my Windows machine eslint was constantly complaining about line endings. Fixed using this answer https://stackoverflow.com/a/53769213
Add ambient typings for another-npm-registry-client
Move types file into types folder
Based on usage. Could use some cleanup
Declare types instead of exporting them for easier use
Improve type declarations for another-npm-registry-client by reading it's docs
Downgrade to match node version
Add some custom type assertions for expected errors
ts-mocha already compiles TS
Instead of building the package using tsc and then running the js file, we can run using ts-node. That way we only need ts files in the project. For this to work a few changes needed to be done:
- Removed the initial empty index file
- Moved bin-files into lib
- Converted bin files to ts and renamed them to index/index-cn
- Changed the shebang in the index files to use ts-node. This also requires ts-node is a dependency of the package
- Adjust tsconfig in order to work with ts-node

Seems like the package still works as intended. It might take a little bit longer to run because of the additional compile step
Seems like mocha requires it
@ComradeVanti
Copy link
Collaborator Author

Also, please note that there's a conflict due to the merging of #50.

I hope to have fixed that now.

@favoyang
Copy link
Member

Also, please note that there's a conflict due to the merging of #50.

I hope to have fixed that now.

Thanks for the rebase. I think my comments have collapsed here: #52 (review), please checkout.

@ComradeVanti
Copy link
Collaborator Author

Thanks for the rebase. I think my comments have collapsed here: #52 (review), please checkout.

Yeah sorry, I force pushed and now all the commits are here twice. But I already responded to your feedback.

@favoyang
Copy link
Member

But I already responded to your feedback.

@ComradeVanti, sorry I didn't see your response for my previous review #52 (review)?

image

@ComradeVanti
Copy link
Collaborator Author

ComradeVanti commented Oct 31, 2023

@favoyang That's weird. Here is how it looks on my side:
image
Maybe something broke because of the force-push or I'm doing something wrong?

@favoyang
Copy link
Member

It says pending. Perhaps there is a button for submitting.

Refs https://github.com/orgs/community/discussions/10369

After much looking, I found the place to "Submit" my review on the "files changed" tab in the upper right hand corner.

@ComradeVanti
Copy link
Collaborator Author

Oh god I feel stupid. Thanks, I hope I did it now.

@favoyang
Copy link
Member

One more thing, please remove ts-node from the dependencies (or move to devDeps if still needed) and regenerate the package-lock.json.

@ComradeVanti
Copy link
Collaborator Author

@favoyang Done. 1fae8e1 and a62fb61

@favoyang
Copy link
Member

Sounds like we're good here. I will give a few more manual tests and merge them tomorrow.

@ComradeVanti
Copy link
Collaborator Author

Cool thanks. I'm a big fan of this project an plan to contribute more. Looking forward to some great collaboration.

@favoyang favoyang merged commit 8e68b9a into openupm:master Nov 1, 2023
2 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 1, 2023
# [1.16.0](1.15.5...1.16.0) (2023-11-01)

### Features

* convert project to TypeScript ([#52](#52)), require node v16 ([8e68b9a](8e68b9a)), closes [/github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21](https://github.com//github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md/issues/version-800-2021-02-21) [/github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21](https://github.com//github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md/issues/version-800-2021-02-21) [/github.com//pull/52#issuecomment-1776779428](https://github.com//github.com/openupm/openupm-cli/pull/52/issues/issuecomment-1776779428) [#50](#50) [/github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21](https://github.com//github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md/issues/version-800-2021-02-21) [/github.com//pull/52#issuecomment-1776779428](https://github.com//github.com/openupm/openupm-cli/pull/52/issues/issuecomment-1776779428) [/github.com//pull/52#discussion_r1375481622](https://github.com//github.com/openupm/openupm-cli/pull/52/issues/discussion_r1375481622) [/github.com//pull/52#discussion_r1378008074](https://github.com//github.com/openupm/openupm-cli/pull/52/issues/discussion_r1378008074)
@favoyang
Copy link
Member

favoyang commented Nov 1, 2023

@ComradeVanti thanks again for all the passion. I have added you to the contributor list.

https://github.com/openupm/openupm-cli#contributors

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.

None yet

2 participants