如何摆脱恼人的打字稿警告

时间:2018-01-04 00:38:42

标签: typescript

App.tsx

export default class Index extends React.Component<any, IAppState> {

警告

ERROR in ./src/Index.tsx
(43,30): error TS2339: Property 'setState' does not exist on type 'Index'.

ERROR in ./src/Index.tsx
(45,30): error TS2339: Property 'setState' does not exist on type 'Index'.

ERROR in ./src/Index.tsx
(60,30): error TS2339: Property 'setState' does not exist on type 'Index'.

ERROR in ./src/Index.tsx
(62,30): error TS2339: Property 'setState' does not exist on type 'Index'.

ERROR in ./src/Index.tsx
(70,18): error TS2339: Property 'state' does not exist on type 'Index'.

Typings.json

{
  "globalDependencies": {
    "immutable": "registry:dt/immutable#3.8.1+20160608070634",
    "redux": "registry:dt/redux#3.5.2+20160703092728",
    "redux-logger": "registry:dt/redux-logger#2.6.0+20160619033847",
    "redux-thunk": "registry:dt/redux-thunk#2.1.0+20160703120921",
    "isomorphic-fetch": "registry:dt/isomorphic-fetch#0.0.0+20160830175641",
    "lodash": "registry:dt/lodash#4.14.0+20161110215204",
    "node": "registry:dt/node#6.0.0+20160928143418",
    "node-uuid": "registry:dt/node-uuid#0.0.0+20160316155526",
    "node-uuid/node-uuid-base": "registry:dt/node-uuid/node-uuid-base#0.0.0+20160316155526",
    "node-uuid/node-uuid-cjs": "registry:dt/node-uuid/node-uuid-cjs#0.0.0+20160316155526",
    "react-bootstrap": "registry:dt/react-bootstrap#0.0.0+20160806072414",
    "react-bootstrap-table": "registry:dt/react-bootstrap-table#2.3.0+20160930122050",
    "react-dom": "registry:dt/react-dom#0.14.0+20160412154040",
    "react-redux": "registry:dt/react-redux#4.4.0+20160908183346",
    "react-router": "registry:dt/react-router#2.0.0+20160928130202",
    "react-router/history": "registry:dt/react-router/history#2.0.0+20160830150755",
    "require": "registry:dt/require#2.1.20+20160919185614"
  },
  "dependencies": {
    "react": "registry:dt/react#15.0.0+20170207010524",
    "react-redux": "registry:dt/react-redux#4.4.0+20170123203653",
    "react-router": "registry:dt/react-router#3.0.0+20170130032908",
    "react-select": "registry:dt/react-select#1.0.0+20170123203653",
    "redux-form": "github:CarsonF/DefinitelyTyped/redux-form/index.d.ts#redux-form-v6"
  }
}

的package.json

"dependencies": {
    "axios": "^0.16.2",
    "es6-promise": "^4.0.5",
    "es6-shim": "^0.35.3",
    "history": "4.6.1",
    "immutable": "^3.8.1",
    "isomorphic-fetch": "^2.2.1",
    "jquery": "^3.2.1",
    "lodash": "^4.17.4",
    "node-sass": "^4.7.2",
    "node-uuid": "^1.4.8",
    "package.json": "^2.0.1",
    "react": "^16.1.0",
    "react-dom": "^16.1.0",
    "shelljs": "^0.7.7",
    "ts-loader": "^2.0.0",
    "typescript": "2.2.0-dev.20170206",
    "webpack": "^1.13.3",
    "webpack-notifier": "^1.4.1"
  },
  "devDependencies": {
    "@types/ajv": "^1.0.0",
    "@types/axios": "^0.14.0",
    "@types/isomorphic-fetch": "0.0.33",
    "@types/jest": "^19.2.2",
    "@types/node": "^7.0.12",
    "axios": "^0.15.3",
    "axios-mock-adapter": "^1.8.1",
    "babel-cli": "^6.24.0",
    "babel-jest": "^19.0.0",
    "babel-polyfill": "^6.16.0",
    "babel-preset-es2017": "^6.22.0",
    "bootstrap": "^3.3.7",
    "colors": "^1.1.2",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.25.0",
    "file-loader": "^0.9.0",
    "grunt": "^1.0.1",
    "i": "^0.3.5",
    "require": "^2.4.20",
    "sass-loader": "^4.0.2",
    "skuid-grunt": "^1.1.3",
    "source-map-loader": "^0.1.5",
    "style-loader": "^0.13.1",
    "url-loader": "^0.5.7",
    "webpack": "^1.13.2",
    "webpack-clean-obsolete-chunks": "^0.1.9",
    "webpack-dev-server": "^1.16.1"
  }

1 个答案:

答案 0 :(得分:0)

可能这个

npm install --dev @types/react @types/react-dom