打字稿,反应错误类型中缺少属性“ [Invalid_propTypes]”

时间:2018-11-30 17:23:40

标签: reactjs typescript react-proptypes

突然我所有的antd组件开始出现相同的错误

  

类型...属性中缺少“属性'[Invalid_propTypes]'”   类型'{子元素:元素;类型'中缺少'[Invalid_propTypes]'地区:   {locale:string;分页:任何; DatePicker:{lang:任何;   timePickerLocale:{占位符:字符串; }; };时间选择器:{   占位符:字符串; };日历:{lang:any; timePickerLocale:{   ...; }; }; ...另外5个...;上传:{...; }; }; }'。”

上面的消息是我在

中收到的示例错误消息

以下是我的package.json

const {authenticate} = require('./../middleware/authenticate');

还有我的tslint.json

{
  "name": "dashboard",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@types/antd": "^1.0.0",
    "@types/axios": "^0.14.0",
    "@types/chart.js": "^2.7.40",
    "@types/classnames": "^2.2.6",
    "@types/prop-types": "^15.5.6",
    "@types/react-helmet": "^5.0.7",
    "@types/react-loadable": "^5.4.1",
    "@types/react-redux": "^6.0.9",
    "@types/react-router-dom": "^4.3.1",
    "@types/react-router-redux": "^5.0.16",
    "@types/redux": "^3.6.0",
    "@types/redux-devtools-extension": "^2.13.2",
    "@types/redux-logger": "^3.0.6",
    "@types/redux-saga": "^0.10.5",
    "@types/redux-thunk": "^2.1.0",
    "autoprefixer": "7.1.6",
    "axios": "^0.18.0",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.2",
    "babel-preset-react-app": "^3.1.2",
    "bootstrap": "^4.1.3",
    "case-sensitive-paths-webpack-plugin": "2.1.1",
    "chalk": "1.1.3",
    "chart.js": "^2.7.3",
    "classnames": "^2.2.6",
    "connected-react-router": "^5.0.1",
    "css-loader": "0.28.7",
    "dotenv": "4.0.0",
    "dotenv-expand": "4.2.0",
    "enquire-js": "^0.2.1",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.5",
    "fork-ts-checker-webpack-plugin": "^0.2.10",
    "fs-extra": "3.0.1",
    "html-webpack-plugin": "2.29.0",
    "immutable": "^4.0.0-rc.12",
    "jest": "20.0.4",
    "object-assign": "4.1.1",
    "peity-react": "0.0.7",
    "postcss-flexbugs-fixes": "3.2.0",
    "postcss-loader": "2.0.8",
    "promise": "8.0.1",
    "raf": "3.4.0",
    "react": "^16.6.3",
    "react-chartjs-2": "^2.7.4",
    "react-container-query": "^0.11.0",
    "react-dev-utils": "^5.0.2",
    "react-dom": "^16.6.3",
    "react-helmet": "^5.2.0",
    "react-loadable": "^5.5.0",
    "react-redux": "^5.1.1",
    "react-redux-spinner": "^1.1.4",
    "react-router-dom": "^4.3.1",
    "react-router-redux": "^4.0.8",
    "react-router5": "^6.5.3",
    "react-saga": "^0.2.6",
    "redux": "^4.0.1",
    "redux-act": "^1.7.4",
    "redux-devtools-extension": "^2.13.5",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "resolve": "1.6.0",
    "source-map-loader": "^0.2.1",
    "style-loader": "0.19.0",
    "sw-precache-webpack-plugin": "0.11.4",
    "ts-jest": "22.0.1",
    "ts-loader": "^2.3.7",
    "tsconfig-paths-webpack-plugin": "^2.0.0",
    "tslint": "^5.7.0",
    "tslint-config-prettier": "^1.10.0",
    "tslint-react": "^3.2.0",
    "uglifyjs-webpack-plugin": "1.2.5",
    "update": "^0.7.4",
    "url-loader": "0.6.2",
    "webpack": "3.8.1",
    "webpack-dev-server": "2.11.3",
    "webpack-manifest-plugin": "1.3.2",
    "whatwg-fetch": "2.0.3"
  },
  "main": "dist/index",
  "typings": "dist/index",
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js --env=jsdom"
  },
  "devDependencies": {
    "@types/jest": "^23.3.9",
    "@types/lodash": "^4.14.118",
    "@types/node": "^10.12.9",
    "@types/react": "^16.7.6",
    "@types/react-custom-scrollbars": "^4.0.5",
    "@types/react-dom": "^16.0.9",
    "antd": "^3.10.9",
    "node-sass": "^4.10.0",
    "react-custom-scrollbars": "^4.2.1",
    "sass-loader": "^7.1.0",
    "typescript": "^3.1.6"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,ts,tsx}",
      "!**/*.d.ts"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.(j|t)s?(x)",
      "<rootDir>/src/**/?(*.)(spec|test).(j|t)s?(x)"
    ],
    "testEnvironment": "node",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.tsx?$": "<rootDir>/config/jest/typescriptTransform.js",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    },
    "moduleFileExtensions": [
      "web.ts",
      "ts",
      "web.tsx",
      "tsx",
      "web.js",
      "js",
      "web.jsx",
      "jsx",
      "json",
      "node",
      "mjs"
    ],
    "globals": {
      "ts-jest": {
        "tsConfigFile": "/home/julio/Documents/Enlyze/dash/dashboard/tsconfig.test.json"
      }
    }
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  }
}

我不知道发生了什么,但是在此突然的错误发生之前,一切都在工作。任何帮助将不胜感激。非常感谢你!

2 个答案:

答案 0 :(得分:0)

尝试在* .d.ts中添加declare module 'antd';

答案 1 :(得分:0)

这是@types/react的问题,只需要升级@ types / react到最新版本即可。

yarn upgrade @types/react@latest