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

[v2] Usage with TypeScript #2675

Closed
Ehesp opened this issue Apr 27, 2020 · 4 comments
Closed

[v2] Usage with TypeScript #2675

Ehesp opened this issue Apr 27, 2020 · 4 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers

Comments

@Ehesp
Copy link

Ehesp commented Apr 27, 2020

🐛 Bug Report

I'm struggling to get TypeScript working with v2. The exported functionality which comes out of the box has a number of issues which are getting flagged. My IDE also complains about these when using standard JS but I can disable the inspection.

To Reproduce

npx @docusaurus/init@next init website

Rename pages/index.js to index.tsx.

I'm getting import errors, such as:

  • TS2307: Cannot find module '@docusaurus/useDocusaurusContext'.
  • TS2307: Cannot find module '@theme/Layout'.
    etc...

I can see within node_modules everything seems to be within the @docusaurus directory, but the exported types don't seem to be working.

Can someone point in in the right direction? Happy to start some docs, but I'm not entirely sure where to start.

@Ehesp Ehesp added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 27, 2020
@lex111
Copy link
Contributor

lex111 commented Apr 28, 2020

@Ehesp this issue should be fixed in v2.0.0-alpha.54. Please use that version. Sorry for that.

@lex111 lex111 closed this as completed Apr 28, 2020
@Ehesp
Copy link
Author

Ehesp commented Apr 28, 2020

Sort of fixed - the @theme ones work, not the @docusaurus ones (see PR)

Latest version works, thanks.

@sebholstein
Copy link

@lex111 I still get this error with 2.0.0-alpha.58

@neo-sam
Copy link
Contributor

neo-sam commented Jul 24, 2020

@SebastianM I successful resolved this error on the current public 58th alpha version flowing the steps below:

  1. read https://v2.docusaurus.io/docs/next/typescript-support/

  2. specify the new version of @docusaurus/module-type-aliases package explicitly at the first step:

    npm i -D @docusaurus/module-type-aliases@next ...other
  3. install @types/react if you use react hooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

4 participants