microsoft / pxt

Microsoft MakeCode (PXT - Programming eXperience Toolkit)
https://makecode.com
MIT License
2.07k stars 579 forks source link

Type Mismatch Errors with @types/react and TypeScript in PXT-Microbit Project #9619

Closed emoltz closed 1 year ago

emoltz commented 1 year ago

Describe the bug When trying to build the PXT-Microbit project, a series of TypeScript errors occur related to the @types/react package. The errors indicate that subsequent property declarations must have the same type, which seems to be a mismatch between the types defined in the @types/react package.

To Reproduce Steps to reproduce the behavior:

Clone the pxt repo run npm i run npm run build Here you should get the type mismatch errors. I went around this by adding a @ts-ignore but the problem persisted when I did the following:

Clone the PXT-Microbit repository (https://github.com/microsoft/pxt-microbit). Run npm install to install the necessary packages. Run pxt serve to build and serve the project. See the TypeScript errors related to @types/react. Expected behavior The project should build without any TypeScript errors and serve locally for development.

Desktop (please complete the following information):

OS: MacOS Node.js Version: LTS TypeScript Version: 4.4.3 @types/react Version: 17.0.5

Additional context I've tried several solutions to resolve these errors, including updating the @types/react package to the latest version, deleting the node_modules directory and reinstalling the packages, and adding "skipLibCheck": true to the tsconfig.json file. Unfortunately, none of these solutions have resolved the issue

jwunderl commented 1 year ago

@emoltz could you run node -v and get the version of node.js you are running?

emoltz commented 1 year ago

18.17.0, but I tried it with 20.5.0 and v14 via nvm

emoltz commented 1 year ago

This is also affecting the build of the pxt repo, i.e. when I run npm run build I get an error related to a type mismatch with the Provider component. This issue seems to extend to all pxt-related repos. Been trying everything to get it to run but to no avail. ChatGPT tells me it is related to the @types/react library, so I am not sure how to fix.

emoltz commented 1 year ago

Fixed: running this on a folder located within an iCloud folder causes the issue.