react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Issue: IDE shows thousands of errors, npm run build gives hundreds on specific tsconfig

Open Ferlorin opened this issue 2 years ago • 1 comments

I do not post as a bug, since according to my previous discussions with several people it seems that there is something just "wrong" probably on my side, however even if the below mentioned issue (b) is my own problem, I cannot understand how (a) affects noone else. I am using Jetbrains Webstorm as an IDE

This happens when I a) open a source file to check the code Image

b) execute "npm run buiild" or "npm run type-check" (Found 430 errors in 139 files.) Image

These are only examples. I find that (b) disappears when instead of my tsconfig being

{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.node.json"
    }
  ]
}

with tsconfig.app.json

{
  "compilerOptions": {
    "composite": true,
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "moduleDetection": "force",
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": ["src"]
}

and tsconfig.node.json

{
  "compilerOptions": {
    "composite": true,
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
    "skipLibCheck": true,
    "module": "ESNext",
    "moduleResolution": "bundler",
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "noEmit": true
  },
  "include": ["vite.config.ts"]
}

it is as per

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
}

I do not understand why the IDE shows so many errors and why the single tsconfig (from doesnt work but the multiple ones work just fine.

Ferlorin avatar Oct 18 '24 07:10 Ferlorin

You seem to have set TypeScript preferences that apply to all dependencies of your project, which is highly uncommon. React-admin has its own set of TypeScript preferences (see https://github.com/marmelab/react-admin/blob/master/tsconfig.json). Your TypeScript settings should only apply to your code, not the code of your dependencies.

Your issue is a TypeScript configuration problem and has nothing to do with a react-admin bug, so I'm going to close it. If you need support without your code, I suggest you head to the project discord or StackOverflow. This issue tracker is only for bug reports.

fzaninotto avatar Oct 18 '24 14:10 fzaninotto