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

TypeScript Checking Issues #3142

Closed
melloware opened this issue Aug 7, 2022 · 2 comments · Fixed by #3156
Closed

TypeScript Checking Issues #3142

melloware opened this issue Aug 7, 2022 · 2 comments · Fixed by #3156
Assignees
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@melloware
Copy link
Member

melloware commented Aug 7, 2022

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 melloware added the Typescript Issue or pull request is *only* related to TypeScript definition label Aug 7, 2022
@melloware melloware added this to the 9.0.0 milestone Aug 7, 2022
@blutorange
Copy link

blutorange commented Aug 7, 2022

@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.

@melloware
Copy link
Member Author

OK that is what I thought should happen but wanted a second set of eyes on it. Much appreciated for your opinion!

@melloware melloware self-assigned this Aug 7, 2022
@melloware melloware added the Status: Discussion Issue or pull request needs to be discussed by Core Team label Aug 7, 2022
melloware added a commit to melloware/primereact that referenced this issue Aug 12, 2022
melloware added a commit to melloware/primereact that referenced this issue Aug 12, 2022
melloware added a commit that referenced this issue Aug 12, 2022
* Fix #3142: Typescript case sensitivity

* Fix #3142: Typescript case sensitivity
@melloware melloware removed the Status: Discussion Issue or pull request needs to be discussed by Core Team label Aug 12, 2022
@mertsincan mertsincan modified the milestones: 9.0.0, 8.4.0 Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
3 participants