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 TypeScript code variant to walkthroughs #5635

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maral
Copy link

@maral maral commented Apr 14, 2024

Description
One of the frequent issues here seems to be the lack of TypeScript example code in the documentation (see the issues linked) - it's upon the user to guess them correctly. I happened to struggle through that a bit too and decided to do something about it instead of complaining.

This PR is a draft at the moment - before converting the whole walkthrough, I would like to get a second opinion first, so I know I am going about it right the first time.

Issue
Fixes: #3895, #4290, #4395, #4915, #5612

Context
The approach I've chosen is to use GitBook's Tabs. For each code snippet (except those explicitly TypeScript-only), I added a tabs wrapper. Even if the snippets are the same for TS and JS, for the consistency I added the tabs there.

Potential problems:

  • The markdown gets a bit verbose and it's not as nice to manage in the long run.
  • TypeScript API might still be changing until the 1.0 version is released.
  • I don't know how to preview the docs - I asked about it on Discord, I didn't get any helpful reply.
  • As far as I found, changing one tab from JS to TS will not change any other tabs, so folks wanting TypeScript (which I hope is the majority) will end up having to switch manually every time they want to copy the code - not ideal. I created an issue in Gitbook's repo, so we'll see if I get any answer there about this.

Checks

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)

Copy link

changeset-bot bot commented Apr 14, 2024

⚠️ No Changeset found

Latest commit: ca637b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dylans
Copy link
Collaborator

dylans commented Apr 21, 2024

This looks useful and is appreciated @maral !

I wouldn't worry too much about things changing with respect to TypeScript, that's basically always a risk with TS.

It would be nice if GitBook has a solution for the issue you mentioned.

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.

Request: Documentation should have a user option to display either TypeScript or JavaScript
2 participants