TypeScript Checking Issues
cc @blutorange
Issue TypeScript check on build
OK so I have added a new script so we can do Typescript compilation checking on the build or running npm run type-check
"type-check": "tsc"
When I run npm run type-check on Windows the TSC works fine and all checks pass. However when it runs on GitHub Actions it fails with...
Error: components/lib/accordion/Accordion.d.ts(2,36): error TS2307: Cannot find module '../csstransition' or its corresponding type declarations.
Error: components/lib/accordion/Accordion.d.ts(3,26): error TS2307: Cannot find module '../utils' or its corresponding type declarations.
Error: components/lib/autocomplete/AutoComplete.d.ts(2,28): error TS2307: Cannot find module '../tooltip/tooltipoptions' or its corresponding type declarations.
....
....
On Windows I had to set this to false to make it work but it seems this may be messing up on Linux.
forceConsistentCasingInFileNames": false,
How do we fix this?
@melloware I checked out the version that's failing on Github actions. On my Ubuntu machine, I can reproduce the failure when running npm run type-check.
As you've guessed, it's because Windows treats file names case insensitively, while MacOS/Linux does not. For example, the file components/lib/csstransition/package.json has the following content
{
"main": "./csstransition.cjs.js",
"module": "./csstransition.esm.js",
"unpkg": "./csstransition.min.js",
"types": "./csstransition.d.ts"
}
The package.json tells TypeScript to use the file components/lib/csstransition/csstransition.d.ts for the types. However, such a file does not exist -- there's components/lib/csstransition/CSSTransition.d.ts, but that's a different file.
forceConsistentCasingInFileNames does not help, since that's more like a Linter rule that adds additional checks that should fail the build on Windows, but it does not make TypeScript treat file names case-insensitively.
The dist seem to be all lower-case, and we should avoid changing that in order not to break anything for consumers of primereact. So I'd say the best way to fix this is by (a) renaming all source files to all lower-case and (b) set forceConsistentCasingInFileNames": true to prevent this from happening again.
OK that is what I thought should happen but wanted a second set of eyes on it. Much appreciated for your opinion!