首页 > 解决方案 > 尝试使用 webpack 和 npm 构建 typescript 项目。发现 33 个错误。我确定它的版本错误,但无法弄清楚

问题描述

ERROR in [at-loader] ./node_modules/@types/react-bootstrap/index.d.ts:20:55
    TS2344: Type 'keyof T' does not satisfy the constraint 'string'.
  Type 'string | number | symbol' is not assignable to type 'string'.
    Type 'number' is not assignable to type 'string'.

ERROR in [at-loader] ./src/components/authentication/Login.tsx:78:67
    TS2345: Argument of type 'typeof LoginComponent' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
  Type 'typeof LoginComponent' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
    Types of parameters 'props' and 'props' are incompatible.
      Type 'RouteComponentProps<any, StaticContext, any>' is not assignable to type 'loginProps'.
        Property 'loginUser' is missing in type 'RouteComponentProps<any, StaticContext, any>'.

ERROR in [at-loader] ./src/components/authentication/Logout.tsx:26:34
    TS2345: Argument of type 'typeof LogoutComponent' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
  Type 'typeof LogoutComponent' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
    Type 'LogoutComponent' is not assignable to type 'Component<RouteComponentProps<any, StaticContext, any>, any, any>'.
      Types of property 'props' are incompatible.
        Type 'Readonly<{ children?: ReactNode; }> & Readonly<logoutProps>' is not assignable to type 'Readonly<{ children?: ReactNode; }> & Readonly<RouteComponentProps<any, StaticContext, any>>'.
          Type 'Readonly<{ children?: ReactNode; }> & Readonly<logoutProps>' is not assignable to type 'Readonly<RouteComponentProps<any, StaticContext, any>>'.
            Property 'location' is missing in type 'Readonly<{ children?: ReactNode; }> & Readonly<logoutProps>'.

ERROR in [at-loader] ./src/components/authentication/Register.tsx:74:70
    TS2345: Argument of type 'typeof RegisterComponent' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
  Type 'typeof RegisterComponent' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
    Types of parameters 'props' and 'props' are incompatible.
      Type 'RouteComponentProps<any, StaticContext, any>' is not assignable to type 'registerProps'.
        Property 'loginUser' is missing in type 'RouteComponentProps<any, StaticContext, any>'.

ERROR in [at-loader] ./src/components/events/CreateEvent.tsx:64:27
    TS2345: Argument of type '{ [x: number]: any; }' is not assignable to parameter of type 'State | Pick<State, "category" | "eventTitle" | "eventDescription" | "eventDateTime" | "eventLocation" | "eventCapacity" | "createResultMessage" | "validationState"> | ((prevState: Readonly<...>, props: Readonly<...>) => State | Pick<...>)'.
  Type '{ [x: number]: any; }' is not assignable to type '(prevState: Readonly<State>, props: Readonly<Props>) => State | Pick<State, "category" | "eventTitle" | "eventDescription" | "eventDateTime" | "eventLocation" | "eventCapacity" | "createResultMessage" | "validationState">'.
    Type '{ [x: number]: any; }' provides no match for the signature '(prevState: Readonly<State>, props: Readonly<Props>): State | Pick<State, "category" | "eventTitle" | "eventDescription" | "eventDateTime" | "eventLocation" | "eventCapacity" | "createResultMessage" | "validationState">'.

ERROR in [at-loader] ./src/components/events/EventListFilter.tsx:45:23
    TS2345: Argument of type '{ [x: number]: any; }' is not assignable to parameter of type 'State | Pick<State, "category"> | ((prevState: Readonly<State>, props: Readonly<Props>) => State | Pick<State, "category">)'.
  Type '{ [x: number]: any; }' is not assignable to type '(prevState: Readonly<State>, props: Readonly<Props>) => State | Pick<State, "category">'.
    Type '{ [x: number]: any; }' provides no match for the signature '(prevState: Readonly<State>, props: Readonly<Props>): State | Pick<State, "category">'.

ERROR in [at-loader] ./src/components/events/EventListFilterContainer.tsx:25:14
    TS2345: Argument of type 'typeof EventListFilter' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
  Type 'typeof EventListFilter' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
    Types of parameters 'props' and 'props' are incompatible.
      Type 'RouteComponentProps<any, StaticContext, any>' is not assignable to type 'Props'.
        Property 'onFilterApplied' is missing in type 'RouteComponentProps<any, StaticContext, any>'.

ERROR in [at-loader] ./src/components/events/EventListPresentation.tsx:130:13
    TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof import("C:/Users/Satwik Gardas/Desktop/EventHawk-master/node_modules/immutability-helper/index")' has no compatible call signatures.

ERROR in [at-loader] ./src/components/navigation/AppRoute.tsx:41:36
    TS2345: Argument of type 'ComponentClass<Pick<AppRouteProps, "children" | "authState" | "history" | "location" | "component" | "render" | "path" | "exact" | "sensitive" | "strict" | "key" | "auth">, any> & { ...; }' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
  Type 'ComponentClass<Pick<AppRouteProps, "children" | "authState" | "history" | "location" | "component" | "render" | "path" | "exact" | "sensitive" | "strict" | "key" | "auth">, any> & { ...; }' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
    Types of property 'propTypes' are incompatible.
      Type 'ValidationMap<Pick<AppRouteProps, "children" | "authState" | "history" | "location" | "component" | "render" | "path" | "exact" | "sensitive" | "strict" | "key" | "auth">>' is not assignable to type 'ValidationMap<RouteComponentProps<any, StaticContext, any>>'.
        Property 'match' is missing in type 'ValidationMap<Pick<AppRouteProps, "children" | "authState" | "history" | "location" | "component" | "render" | "path" | "exact" | "sensitive" | "strict" | "key" | "auth">>'.

ERROR in [at-loader] ./src/components/navigation/DropSidebar.tsx:25:26
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/components/navigation/DropSidebar.tsx:25:33
    TS7006: Parameter 'e' implicitly has an 'any' type.

ERROR in [at-loader] ./src/components/navigation/Header.tsx:52:34
    TS2345: Argument of type 'ComponentClass<Pick<any, never>, any> & { WrappedComponent: ComponentClass<any, any> | StatelessComponent<any>; }' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
  Type 'ComponentClass<Pick<any, never>, any> & { WrappedComponent: ComponentClass<any, any> | StatelessComponent<any>; }' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
    Types of property 'propTypes' are incompatible.
      Type 'ValidationMap<Pick<any, never>>' is not assignable to type 'ValidationMap<RouteComponentProps<any, StaticContext, any>>'.
        Property 'history' is missing in type 'ValidationMap<Pick<any, never>>'.

ERROR in [at-loader] ./src/components/navigation/Sidebar.tsx:73:80
    TS2345: Argument of type 'typeof SidebarComponent' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
  Type 'typeof SidebarComponent' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
    Types of parameters 'props' and 'props' are incompatible.
      Type 'RouteComponentProps<any, StaticContext, any>' is not assignable to type 'SidebarProps'.
        Property 'onFilterApplied' is missing in type 'RouteComponentProps<any, StaticContext, any>'.

ERROR in [at-loader] ./src/layout/App.tsx:35:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:36:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:38:31
    TS2339: Property 'history' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:46:28
    TS2339: Property 'history' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ loginUser: (data: AuthenticationState) => void; }, never>, any, any>> & Readonly<{ children?: ReactNode; }> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:54:31
    TS2339: Property 'history' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ loginUser: (data: AuthenticationState) => void; }, never>, any, any>> & Readonly<{ children?: ReactNode; }> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:59:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:60:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:67:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:68:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:75:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:76:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:83:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:84:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:86:47
    TS2339: Property 'history' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:91:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:99:33
    TS2339: Property 'type' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/layout/App.tsx:100:33
    TS2339: Property 'event' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<{ authState: AuthenticationState; filters: EventListFilterSetting; } & { onFilterApplied: (newFilter: EventListFilterSetting) => void; }, never>, any, any>> & Readonly<...> & Readonly<...>'.

ERROR in [at-loader] ./src/services/exceptions.tsx:9:9
    TS2556: Expected 0-1 arguments, but got 2 or more.

ERROR in [at-loader] ./src/services/exceptions.tsx:28:9
    TS2556: Expected 0-1 arguments, but got 2 or more.

ERROR in [at-loader] ./src/views/HomeView.tsx:93:81
    TS2345: Argument of type 'typeof HomeViewComponent' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
  Type 'typeof HomeViewComponent' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
    Types of parameters 'props' and 'props' are incompatible.
      Type 'RouteComponentProps<any, StaticContext, any>' is not assignable to type 'IHomeProps'.
        Property 'onFilterApplied' is missing in type 'RouteComponentProps<any, StaticContext, any>'.

我的配置文件:

{
  "name": "eventhawk",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "heroku-postbuild": "node_modules/.bin/webpack",
    "start": "node_modules/.bin/webpack && node app.js"
  },
  "dependencies": {
    "@types/axios": "^0.14.0",
    "@types/body-parser": "^1.16.5",
    "@types/d3": "^4.12.0",
    "@types/express": "^4.0.37",
    "@types/immutability-helper": "^2.0.15",
    "@types/jwt-decode": "^2.2.1",
    "@types/react": "^16.0.9",
    "@types/react-bootstrap": "^0.31.4",
    "@types/react-dom": "^16.0.0",
    "@types/react-redux": "^5.0.12",
    "@types/react-router": "^4.0.17",
    "@types/react-router-bootstrap": "^0.24.2",
    "@types/react-router-dom": "^4.0.8",
    "@types/redux-logger": "^3.0.5",
    "axios": "^0.16.2",
    "body-parser": "^1.18.2",
    "d3": "^4.12.0",
    "express": "^4.16.1",
    "immutability-helper": "^2.5.0",
    "import-loader": "^1.0.1",
    "jwt-decode": "^2.2.0",
    "moment": "^2.19.2",
    "react": "^16.0.0",
    "react-bootstrap": "^0.31.3",
    "react-datetime": "^2.11.0",
    "react-dom": "^16.0.0",
    "react-redux": "^5.0.6",
    "react-router": "^4.2.0",
    "react-router-bootstrap": "^0.24.4",
    "react-router-dom": "^4.2.2",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "source-map-loader": "^0.2.2"
  },
  "devDependencies": {
    "awesome-typescript-loader": "^3.5.0",
    "typescript": "^3.1.1",
    "webpack": "^3.12.0"
  }
}

标签: reactjstypescriptnpmwebpack

解决方案


推荐阅读