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

Add JSDocs to generated projects #1334

Merged
merged 25 commits into from
Oct 18, 2023
Merged

Add JSDocs to generated projects #1334

merged 25 commits into from
Oct 18, 2023

Conversation

frandiox
Copy link
Contributor

WHY are these changes introduced?

We already have GraphQL Codegen for TypeScript but JS projects are not getting any benefits from it. This adds JSDocs to the generated JS projects.

WHAT is this pull request doing?

This uses ts-morph to transpile TS => JS and also generate JSDocs at the same time from the TS types.

First, it adds typedefs for each type at the bottom:

image

Then, it annotates each function using the types defined:

image

HOW to test your changes?

In the templates folder, run:

h2 init --path jsdocs --language js --force --styling none --mock-shop --no-shortcut --markets domains --no-install-deps --routes && cd jsdocs && ln -s ../../node_modules node_modules

Check that the generated project has JSDocs and works with Codegen. You might need to >TypeScript: Restart TS Server in VSCode at times.

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

@frandiox frandiox requested a review from a team September 13, 2023 12:37
@github-actions

This comment has been minimized.

Copy link
Member

@benjaminsehl benjaminsehl left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀🦐

@frandiox frandiox mentioned this pull request Oct 12, 2023
4 tasks
@@ -42,7 +42,7 @@
"gunzip-maybe": "^1.4.2",
"prettier": "^2.8.4",
"tar-fs": "^2.1.1",
"typescript": "^5.2.2",
"ts-morph": "19.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW ts-morph adds about 13mb to the install: https://pkg-size.dev/ts-morph

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but it replaces typescript, which is 41mb. Creating a new Hydrogen project (i.e. installing the CLI globally) should now download 28mb less than before 😄

}

/**
* @license MIT (https://github.com/futurGH/ts-to-jsdoc/blob/67b5e548a30b9cb5bf74f200168ffddab9d8600e/LICENSE)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@blittle just to double check, do you think it's OK to include this license here in this file?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, looks like it should be okay, as long as we keep the copyright notice: https://memgraph.com/blog/what-is-mit-license#:~:text=2.%20Does%20the%20MIT%20License%20allow%20commercial%20use%3F

@frandiox frandiox merged commit e992de2 into main Oct 18, 2023
9 checks passed
@frandiox frandiox deleted the fd-js-types branch October 18, 2023 08:51
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