Skip to content

Create a Tab on docusaurus for Typescript implementations #696

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

Closed
pedroapfilho opened this issue Nov 29, 2020 · 9 comments
Closed

Create a Tab on docusaurus for Typescript implementations #696

pedroapfilho opened this issue Nov 29, 2020 · 9 comments

Comments

@pedroapfilho
Copy link
Contributor

I came across the Setup on the React docs, and I found this.

Using it with typescript is a little bit tricky for new comers, and I think that it may happen with a lot of people, so what if we use the new Markdown Feature for Docusaurus that allows us to create Tabs on the docs that are for JS, and use:

<Tabs
  groupId="test-utils"
  defaultValue="js"
  values={[
    {label: 'Javascript', value: 'js'},
    {label: 'Typescript', value: 'tsx'},
  ]}>
  <TabItem value="win">Code for JS here</TabItem>
  <TabItem value="mac">Code for TS here</TabItem>
</Tabs>

So we could have more people using it right with `Typescript.

Is it a good idea? I can implement it here at first, and then we take it as a default and implement it everywhere else, whenever we touch it.

Material-UI did it on their docs, and I find it so much better to use it like this. Idk if they use Docusaurus, but it's easily implementable..`

@MatanBobi
Copy link
Member

Hi @pedroapfilho, thanks for opening this!
It sounds good to me, we've already added Tabs and TabItem in some docs and there's also a code snippet for vscode to generate those.
Since we don't have typescript blocks in the docs yet, maybe it would be better to have another opinion..
@nickmccurdy, @kentcdodds wdyt about this one?

@kentcdodds
Copy link
Member

Seems to make sense to me if anyone's willing to do the work there.

@pedroapfilho
Copy link
Contributor Author

Alright, I'll start then!

@nickserv
Copy link
Member

Would it be possible to have the TypeScript code typechecked and compiled to the JavaScript code automatically to keep the types and both code examples in sync?

@kentcdodds
Copy link
Member

I'd be worried about the compiled version looking like.... compiled code 😅 But it's possible that the right babel plugins + prettier could be used to only remove types 🤔

@nickserv
Copy link
Member

As far as I understand that's pretty much what @babel/preset-typescript does.

@pedroapfilho
Copy link
Contributor Author

@nickmccurdy Do you have any examples of it somewhere I can see?

@nickserv
Copy link
Member

Examples of what?

@pedroapfilho
Copy link
Contributor Author

Of any docusaurus docs that has this setup

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

No branches or pull requests

4 participants