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

Fresh Typescript Project Throws Errors #5189

Closed
brettdoyle44 opened this issue Apr 15, 2022 · 5 comments · Fixed by #5192
Closed

Fresh Typescript Project Throws Errors #5189

brettdoyle44 opened this issue Apr 15, 2022 · 5 comments · Fixed by #5192
Labels
bug/confirmed We have confirmed this is a bug topic/typescript

Comments

@brettdoyle44
Copy link

Overview:

When creating a new redwoodjs typescript project it throws errors in multiple files in VSCode. The two biggest are on Router and App.tsx. I have tried to use David's solution in the following forum post, but as soon as I spin up dev the errors return: https://community.redwoodjs.com/t/i-see-red-squiggles-how-to-fix-type-warnings-in-vs-code/2961.

Current versions:
Node v16.13.0
Yarn v1.22.18

Steps to replicate:

  1. yarn create redwood-app typescript-test --typescript
  2. cd into project and run yarn rw dev
  3. go into project in VSCode
  4. errors show like below:

Screen Shot 2022-04-15 at 10 11 41 AM
Screen Shot 2022-04-15 at 10 11 50 AM

@jtoar jtoar self-assigned this Apr 15, 2022
@jtoar
Copy link
Contributor

jtoar commented Apr 15, 2022

Hey @brettdoyle44, thanks for reporting this! Would you mind running two commands and pasting the output here to confirm some things? I think this may be the same issue as #5104 which means our latest fix here #5165 didn't work.

yarn rw --version
yarn why @types/react-dom

The output I see is:

# First command
1.0.1

# Second command
├─ @redwoodjs/testing@npm:1.0.1
│  └─ @types/react@npm:17.0.40 (via npm:17.0.40)
│
├─ @types/react-dom@npm:17.0.14
│  └─ @types/react@npm:18.0.5 (via npm:*)
│
├─ @types/react-dom@npm:18.0.1
│  └─ @types/react@npm:18.0.5 (via npm:*)
│
└─ @types/react-syntax-highlighter@npm:11.0.5
   └─ @types/react@npm:18.0.5 (via npm:*)

@jtoar jtoar added bug/confirmed We have confirmed this is a bug topic/typescript labels Apr 15, 2022
@thedavidprice
Copy link
Contributor

Thanks for reporting @brettdoyle44 Turns out the whole of the internet using React + TS is experiencing this, but I did have it resolved — apparently not for all cases. There are a lot of Issues open on DefinitelyTyped. I'm following this one by the Microsoft Team: microsoft/DefinitelyTyped-tools#433

Gah, this behavior is so frustrating... 🤬

Also, it works after upgrading to canary. Why?!?

Reproduction steps to resolve with Canary version

  1. Fresh install: yarn create redwood-app my-dir --ts
  2. cd my-dir && yarn rw type-check [FAILS]
  3. yarn dedupe && yarn rw type-check [FAILS]
  4. yarn rw upgrade -t canary && yarn rw type-check [PASSES]

The canary version has the same dep resolution as the latest. The upgrade command runs yarn dedupe or the Yarn 1 npx yarn-deduplicate equivalent. But what else would be different here such that is resolves correctly for upgrade canary but not on a new project?

Ah, there might be a more recent version of the packages... I could try that as well.

And/or there might be something else about canary that makes it resolve correctly -- I'll find out with an RC today.

@jtoar jtoar removed their assignment Apr 15, 2022
@thedavidprice
Copy link
Contributor

got it. will fix via 1.0.2 coming asap

@brettdoyle44
Copy link
Author

@thedavidprice Upgrading the project to Canary worked for me. I am just starting on my project, so should I wait for v1.0.2 to start fresh project?

@jtoar
Copy link
Contributor

jtoar commented Apr 16, 2022

Hey @brettdoyle44 1.0.2 is out now. It's different from the canary because we only cherry picked the changes we needed, so it may be more stable to stick to 1.0.2 if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/confirmed We have confirmed this is a bug topic/typescript
Projects
No open projects
Status: Archived
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants