I've created a react project using yarn and create-react-app with the typescript template and it worked fine even after installing and using other modules.
After that I used yarn add react-window and yarn add @types/react-window --dev the following error is raised:
yarn run v1.22.5
$ react-scripts build
Creating an optimized production build...
Failed to compile.
/app/src/components/Table.tsx
TypeScript error in /app/src/components/Table.tsx(1,31):
Could not find a declaration file for module 'react-window'. '/app/node_modules/react-window/dist/index.cjs.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/react-window` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-window';` TS7016
> 1 | import { FixedSizeList } from "react-window";
| ^
2 | import AutoSizer from "react-virtualized-auto-sizer";
3 | import InfiniteLoader from "react-window-infinite-loader";
4 | import { LISTINGS_ENDPOINT } from "../../endpoints";
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Even after running npm i --save-dev @types/react-window in my dev environment it still results in the same error.
The app runs in docker and fails on the RUN yarn build command. There were no issues prior to using react-window.
What is happening? Other posts on stack overflow regarding this error were solved by installing the types modules (for different libraries), or setting noImplicitAny to false such as here.
@types/react-windowactually make it into yourpackage.json?devDependencies, the build seems to work now that I manually put it underdependenciesinstead and ranyarnagain. Should I have usedyarn add @types/react-windowinstead ofyarn add @types/react-window --dev?node_modules, and the resolution of those modules at build time depends on them being innode_modules. hmm...