While working on a repository with Yarn workspaces, I encountered an issue. When I use tsc --noEmit
to perform type checking within the workspace folder, errors are appearing for packages stored in the top-level node_modules
directory.
../../node_modules/create-emotion-styled/types/index.d.ts:5:24 - error TS7016: ...
../../node_modules/create-react-context/lib/index.d.ts:1:24 - error TS7016: ...
../../node_modules/react-i18next/index.d.ts:1:24 - error TS7016: ...
All these errors seem to be related to missing React types:
Could not find a declaration file for module 'react'.
Even though I have @types/react
installed locally in my workspace, it doesn't resolve the issue. According to the documentation:
The "exclude" property usually excludes the node_modules, bower_components, and jspm_packages directories by default.
I've attempted using
exclude: ["**/node_modules", "**/node_modules/**"]
but unfortunately, the errors persist. So why exactly are these errors popping up?