aspnet / Templating

[Archived] ASP.NET Core templates for .NET CLI and Visual Studio. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
205 stars 79 forks source link

Typescript 2.6 errors in reactredux template #138

Closed virzak closed 6 years ago

virzak commented 6 years ago

typescript 2.6 has long awaited // #region support, but as soon as the upgrade is made, errors occur in the unmodified template.

Most are easy to fix, but is there a quick fix for this one?

ERROR in [at-loader] ./ClientApp/routes.tsx:10:12 
    TS2322: Type '{ path: "/counter"; component: typeof Counter; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Route> & Readonly<{ children?: ReactNode; }> & Rea...'.
  Type '{ path: "/counter"; component: typeof Counter; }' is not assignable to type 'Readonly<RouteProps>'.
    Types of property 'component' are incompatible.
      Type 'typeof Counter' is not assignable to type 'StatelessComponent<RouteComponentProps<any> | undefined> | ComponentClass<RouteComponentProps<any...'.
        Type 'typeof Counter' is not assignable to type 'ComponentClass<RouteComponentProps<any> | undefined>'.
          Types of parameters 'props' and 'props' are incompatible.
            Type 'RouteComponentProps<any> | undefined' is not assignable to type 'CounterProps | undefined'.
              Type 'RouteComponentProps<any>' is not assignable to type 'CounterProps | undefined'.
                Type 'RouteComponentProps<any>' is not assignable to type 'CounterProps'.
                  Type 'RouteComponentProps<any>' is not assignable to type 'CounterState'.
                    Property 'count' is missing in type 'RouteComponentProps<any>'.
Havret commented 6 years ago

The problem is with compose function from redux. Just past these tests and see that const t7 is failing under Typescript 2.6.

virzak commented 6 years ago

The band-aid solution is to add as any if anyone interested

    <Route exact path='/' component={ Home } />
    <Route path='/counter' component={Counter as any } />
    <Route path='/fetchdata/:startDateIndex?' component={ FetchData as any } />
SteveSandersonMS commented 6 years ago

This problem will no longer be applicable in the next version of the ReactRedux template (it's based on create-react-app). In effect it's fixed, so I'll close this.

For anyone needing to update apps created with the 2.0.x SDK, please see @virzak's comment.