2017-08-02 15 views
6

Tôi đã cài đặt @ loại/phản ứng-dom cùng với loại và @ loại/phản ứng và @ loại/sao băng nhưng khi tôi cố gắng chạy trình gõ từ dòng lệnh tôi nhận được lỗi dưới đâyLỗi tại node_modules/@ types/react-dom/.... Các khai báo biến tiếp theo phải có cùng loại. Biến 'a'

Bạn có thể tạo lại lỗi và xem tất cả cấu hình của tôi tại đây: https://github.com/Falieson/react15-meteor1.5

Cảm ơn sự giúp đỡ của bạn!

$ meteor npm run type:client 

> [email protected] type:client /Users/sjcfmett/Private/ReactMeteorExample 
> tslint -p ./tsconfig.json --type-check './client/**/*.{ts,tsx}' 

Error at node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3422:13: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'. 
Error at node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3423:13: Subsequent variable declarations must have the same type. Variable 'abbr' must be of type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>', but here has type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>'. 
Error at node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3424:13: Subsequent variable declarations must have the same type. Variable 'address' must be of type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>', but here has type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>'. 
Error at node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3425:13: Subsequent variable declarations must have the same type. Variable 'area' must be of type 'DetailedHTMLProps<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>', but here has type 'DetailedHTMLProps<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>'. 
... (shortened) 

package.json (để tham khảo)

{ 
    "name": "react-meteor-example", 
    "version": "0.1.0", 
    "private": true, 
    "scripts": { 
    "start": "meteor run", 
    "lint:client": "tslint --fix -c ./tslint.json -p ./tsconfig.json './client/**/*.{ts,tsx}'", 
    "lint:imports": "tslint --fix -c ./tslint.json -p ./tsconfig.json './imports/**/*.{ts,tsx}'", 
    "lint:server": "tslint --fix -c ./tslint.json -p ./tsconfig.json './server/**/*.ts'", 
    "lint": "npm run lint:client && npm run lint:server && npm run lint:imports", 
    "type:imports": "tslint -p ./tsconfig.json --type-check './imports/**/*.{ts,tsx}'", 
    "type:client": "tslint -p ./tsconfig.json --type-check './client/**/*.{ts,tsx}'", 
    "type:server": "tslint -p ./tsconfig.json --type-check './server/**/*.ts'", 
    "type": "npm run type:client && npm run type:server && npm run type:imports", 
    "precommit": "npm run lint && npm run type" 
    }, 
    "dependencies": { 
    "babel-runtime": "^6.20.0", 
    "meteor-node-stubs": "~0.2.4", 
    "react": "^15.6.1", 
    "react-dom": "^15.6.1" 
    }, 
    "devDependencies": { 
    "@types/meteor": "^1.4.2", 
    "@types/react": "^15.6.0", 
    "@types/react-dom": "^15.5.1", 
    "babel-preset-react": "^6.24.1", 
    "babel-preset-stage-1": "^6.24.1", 
    "husky": "^0.14.3", 
    "tslint": "^5.5.0", 
    "tslint-react": "^3.1.0", 
    "typescript": "^2.4.2" 
    } 
} 

Trả lời

4

Các loại cho Phản ứng 16 beta đã được công bố là 'mới nhất' Phản ứng loại.

Phiên bản mới loại bỏ các định nghĩa cho các phần của React đã được gỡ bỏ trong React 16 (như React.DOM), được mong đợi.

Thật không may, việc xuất bản các loại này cho React 16 beta đã được thực hiện cho thẻ @latest (mặc định) trong npm thay vì @next (như React đã làm).

Tôi gặp sự cố mở (# 18.708) với DefinitelyTyped đây: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18708

Bạn có thể thử đặc biệt nhắm mục tiêu một thông cáo đặc biệt (npm install --save @types/[email protected]) nhưng sự phụ thuộc trong các loại @/phản ứng-dom với nhiều loại @/phản ứng được thiết lập thành "*", có vẻ như gây ra @ loại/phản ứng @ mới nhất để vẫn được tải xuống, khiến bạn có nhiều phiên bản ở nhiều nơi khác nhau trong thư mục node_modules của bạn.

Chúng tôi đang phải thực hiện một số công việc thủ công để sắp xếp việc này. Hy vọng rằng các folks duy trì @ loại/phản ứng sẽ sửa lỗi này sớm.

0

Tôi đang sử dụng sợi, và cố định này bằng cách chạy rm -rf node_modules && rm yarn.lock && yarn install

+0

Chỉ cần để mà folks nhận thức được - nếu bạn đang dựa vào sợi như một người quản lý gói, sau đó lệnh này được busting toàn bộ mục đích của 'yarn'. Mặc dù nó chắc chắn sửa vấn đề :) Mặt khác, bạn chỉ có thể chạy 'npm install' để thay thế – Dethariel

Các vấn đề liên quan