primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.9k stars 1.05k forks source link

Cannot find module '../utils/Utils' or its corresponding type declarations. #2462

Closed fregante closed 2 years ago

fregante commented 2 years ago

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Codesandbox Case (Bug Reports)

If you haven't caught it until now, it means it Codesandbox can't replicate it.

Current behavior


node_modules/primereact/treenode/treenode.d.ts:1:24 - error TS2307: Cannot find module '../utils/Utils' or its corresponding type declarations.

1 import {IconType} from "../utils/Utils";
                         ~~~~~~~~~~~~~~~

Found 1 error.

Expected behavior

No error

Minimal reproduction of the problem with instructions

On a case-sensitive FS

npm install primereact
npm install @types/react
npm install typescript
echo 'import { TreeTable } from "primereact/treetable";' > index.ts
echo '{"files": ["index.ts"], "compilerOptions": {"lib": ["ES2019"]}}' > tsconfig.json
npx tsc

GitHub Actions

You can test this on GHA since it's case-sensitive. The output can currently be seen at https://github.com/fregante/sandbox/runs/4299166102?check_suite_focus=true

name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v2
        with:
          node-version: "16"
      - run: npm install primereact
      - run: npm install @types/react
      - run: npm install typescript
      - run: echo 'import { TreeTable } from "primereact/treetable";' > index.ts
      - run: |
          echo '{"files": ["index.ts"], "compilerOptions": {"lib": ["ES2019"]}}' > tsconfig.json
      - run: npx tsc

Please tell us about your environment:

GitHub Actions, runs-on: ubuntu-latest

melloware commented 2 years ago

This looks pervasive throughout the codebase?

fregante commented 2 years ago

What you're using to build the files seem to take care of that and it's not causing an issue elsewhere. The issue here is specific to this hand-rolled d.ts file that is breaking TypeScript. Once I fix this file my issue disappears.

fregante commented 2 years ago

Oh I suppose I'm seeing only this issue because that's the component I'm using. Let me update the PR

VsevolodGolovanov commented 2 years ago

I'm importing

import {InputText, InputTextProps} from "primereact/inputtext";
import {InputTextarea, InputTextareaProps} from "primereact/inputtextarea";
import {Button} from "primereact/button";
import {Dialog} from "primereact/dialog";
import {ListBox, ListBoxProps} from "primereact/listbox";
import {Checkbox} from "primereact/checkbox";
import {MultiSelect} from "primereact/multiselect";
import TooltipOptions from "primereact/tooltip/tooltipoptions";
import {ObjectUtils} from "primereact/utils";

and getting the error

C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/src/ext-argus-deps/SystemInfComp.tsx
TypeScript error in C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/src/ext-argus-deps/SystemInfComp.tsx(32,27):
File name 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/utils/utils.d.ts' differs from already included file name 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/utils/Utils.d.ts' only in casing.
  The file is in the program because:
    Imported via "../utils/Utils" from file 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/button/button.d.ts' with packageId 'primereact/utils/Utils.d.ts@7.0.1'
    Imported via "../utils/Utils" from file 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/calendar/calendar.d.ts' with packageId 'primereact/utils/Utils.d.ts@7.0.1'
    Imported via '../utils/Utils' from file 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/multiselect/multiselect.d.ts' with packageId 'primereact/utils/Utils.d.ts@7.0.1'
    Imported via "../utils/Utils" from file 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/treenode/treenode.d.ts' with packageId 'primereact/utils/Utils.d.ts@7.0.1'
    Imported via '../utils/Utils' from file 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/autocomplete/autocomplete.d.ts' with packageId 'primereact/utils/Utils.d.ts@7.0.1'
    Imported via "../utils/Utils" from file 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/splitbutton/splitbutton.d.ts' with packageId 'primereact/utils/Utils.d.ts@7.0.1'
    Imported via "../utils/Utils" from file 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/node_modules/primereact/checkbox/checkbox.d.ts' with packageId 'primereact/utils/Utils.d.ts@7.0.1'
    Imported via "primereact/utils" from file 'C:/work/argus/rep/TechService-3.22-alt/workspace/server-app/inf-modules/system-inf-ui/src/main/resources/META-INF/resources/views/system/inf/page/showcase/react/src/ext-argus-deps/SystemInfComp.tsx'  TS1149

    30 | import _ from "lodash";
    31 | import ReactDOM from "react-dom";
  > 32 | import {ObjectUtils} from "primereact/utils";
       |                           ^
    33 | import TooltipOptions from "primereact/tooltip/tooltipoptions";
    34 | import jQuery from "jquery";
    35 |

because PrimeReact in checkbox.d.ts and other files imports Utils - first letter in uppercase. But the actual file is named utils.d.ts - I guess, your build process names it that? Anyway, this can be ignored by configuring forceConsistentCasingInFileNames to be false in tsconfig.json. It was set to true by default in my CRA based project.

Seems like fregante's PR should fix this.

melloware commented 2 years ago

@VsevolodGolovanov I get the same exact error message. Was hoping this would fix it.

AuthorProxy commented 2 years ago

the same error on MacOsx, but on Ubuntu everything is ok, looks like button.d.ts referencing utils/Utils causing an error