Typescript-react-starter: Type checking error after fresh install

Created on 27 Nov 2017  路  4Comments  路  Source: microsoft/TypeScript-React-Starter

/Users/[MYUSERNAME]/projects/playground/node_modules/@types/react/index.d.ts
(3554,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'col' must be of type 'DetailedHTMLProps, HTMLTableColElement>', but here has type 'DetailedHTMLProps, HTMLTableColElement>'.

Most helpful comment

EDIT: I've found what I think is the better / correct solution, based on further searching and discovery of this issue and this one.

The problem seems to be conflicting @types versions. To resolve the issue, I updated the dependencies in package.json to require the latest (compatible) versions of @types/react-dom and @types/react-dom

  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts-ts": "2.13.0"
  },
  "devDependencies": {
    "@types/jest": "^22.2.0",
    "@types/node": "^9.4.6",
    "@types/react": "^16.0.40",
    "@types/react-dom": "^16.0.4", <--聽(was聽^15.something)
    "typescript": "^2.7.2"
  }

then deleted the node-modules/@types folder, and re-installed. This seems to more properly resolve the issue. To summarize the solution:

  1. update the @types dependencies for @types/react-dom in package.json to the latest compatible version (listed here, and here, if you also need to update the react typings, although this was not necessary for me).
  2. delete the existing node_modules/@types folder
  3. run npm install
  4. now npm run start should just work

OLD/ALTERNATE SOLUTION:

I was also getting basically the same error as @wujian-nerc above, and after some googling of the error message (which seems to be very common), found this thread. The suggestion at this particular comment:

Adding React to the paths object in my tsconfig.json file solved the issue for me for now:

{
   "compilerOptions": {
       "typeRoots": [
           "node_modules/@types"
       ],
       "paths": {
           "react": ["node_modules/@types/react"] <---Here
       }
}

temporarily does resolve the issue.

All 4 comments

I get the same error after a fresh install, the error goes away when i delete the rules object in the tsling.json files ... I also didn't find a solution for that one, can any one help, thank you .

I got the same error!

/[MYAPP]/node_modules/@types/react-dom/node_modules/@types/react/index.d.ts
(3631,13): Subsequent property declarations must have the same type. Property 'a' must be of type 'DetailedHTMLProps, HTMLAnchorElement>', but here has type 'DetailedHTMLProps, HTMLAnchorElement>'.

node --version
v6.9.2
npm --version
3.10.9
create-react-app --version
1.4.3
react
version: 16.2.0
react-dom
version: 16.2.0

@zmazouzi delete the rules object in the tslint.json not working for me.

EDIT: I've found what I think is the better / correct solution, based on further searching and discovery of this issue and this one.

The problem seems to be conflicting @types versions. To resolve the issue, I updated the dependencies in package.json to require the latest (compatible) versions of @types/react-dom and @types/react-dom

  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts-ts": "2.13.0"
  },
  "devDependencies": {
    "@types/jest": "^22.2.0",
    "@types/node": "^9.4.6",
    "@types/react": "^16.0.40",
    "@types/react-dom": "^16.0.4", <--聽(was聽^15.something)
    "typescript": "^2.7.2"
  }

then deleted the node-modules/@types folder, and re-installed. This seems to more properly resolve the issue. To summarize the solution:

  1. update the @types dependencies for @types/react-dom in package.json to the latest compatible version (listed here, and here, if you also need to update the react typings, although this was not necessary for me).
  2. delete the existing node_modules/@types folder
  3. run npm install
  4. now npm run start should just work

OLD/ALTERNATE SOLUTION:

I was also getting basically the same error as @wujian-nerc above, and after some googling of the error message (which seems to be very common), found this thread. The suggestion at this particular comment:

Adding React to the paths object in my tsconfig.json file solved the issue for me for now:

{
   "compilerOptions": {
       "typeRoots": [
           "node_modules/@types"
       ],
       "paths": {
           "react": ["node_modules/@types/react"] <---Here
       }
}

temporarily does resolve the issue.

@DM-Berger Thanks! It works.
Here is what I have done:

  1. delete node_modules/@types
  2. update the package.json in edit "@types/react-dom": "16.0.4",
  3. npm i
    And that works
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Yang09701194 picture Yang09701194  路  7Comments

masters3d picture masters3d  路  6Comments

JukoPowel picture JukoPowel  路  3Comments

corydeppen picture corydeppen  路  6Comments

wilomgfx picture wilomgfx  路  6Comments