Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Typescript: Incorrect types on class Component #98

Open
ghost opened this issue Jun 24, 2019 · 4 comments
Open

Typescript: Incorrect types on class Component #98

ghost opened this issue Jun 24, 2019 · 4 comments
Labels
help wanted The owner cannot resolve this on their own. more info needed The issue requires more information. support A user is requesting support.

Comments

@ghost
Copy link

ghost commented Jun 24, 2019

"react": "^16.8.1",
"reactn": "^2.1.4",

When using reactn as: import React, { Component } from 'reactn'

TypeScript fails with the following:

Class static side 'typeof Form' incorrectly extends base class static side '{ propTypes?: WeakValidationMap<{}> | undefined; contextType?: Context<any> | undefined; contextTypes?: ValidationMap<any> | undefined; childContextTypes?: ValidationMap<any> | undefined; defaultProps?: Partial<...> | undefined; displayName?: string | undefined; getDerivedStateFromProps?: GetDerivedStateFromProps<.....'.
  Type 'typeof Form' is not assignable to type '{ propTypes?: WeakValidationMap<{}> | undefined; contextType?: Context<any> | undefined; contextTypes?: ValidationMap<any> | undefined; childContextTypes?: ValidationMap<any> | undefined; defaultProps?: Partial<...> | undefined; displayName?: string | undefined; getDerivedStateFromProps?: GetDerivedStateFromProps<.....'.
    Types of property 'getDerivedStateFromProps' are incompatible.
      Type '(nextProps: Props, prevState: State) => { prevPath: string; } | null' is not assignable to type 'GetDerivedStateFromProps<{}, {}>'.
        Types of parameters 'nextProps' and 'nextProps' are incompatible.
          Type 'Readonly<{}>' is not assignable to type 'Props'.
            Type 'Readonly<{}>' is missing the following properties from type 'RouteComponentProps<RouteParams, StaticContext, any>': history, location, match  TS2417

    54 | }
    55 | 
  > 56 | class Form extends Component<Props, State> {
       |       ^
    57 |   constructor(props: Props) {
    58 |     super(props)
    59 | 

@CharlesStover, do you have any idea why? Any help would be appreciated

@quisido
Copy link
Collaborator

quisido commented Jun 24, 2019

Thanks for reporting this. Does your Form class have a getDerivedStateFromProps static method?

@quisido quisido added the more info needed The issue requires more information. label Jun 24, 2019
@ghost
Copy link
Author

ghost commented Jun 25, 2019

Hi @CharlesStover, no it does not

@quisido
Copy link
Collaborator

quisido commented Jun 25, 2019

What version of TypeScript are you using? You can find them via npm ls typescript.

@ghost
Copy link
Author

ghost commented Jun 26, 2019

"typescript": "^3.4.5"

@quisido quisido added the support A user is requesting support. label Aug 8, 2019
@quisido quisido added the help wanted The owner cannot resolve this on their own. label Nov 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted The owner cannot resolve this on their own. more info needed The issue requires more information. support A user is requesting support.
Projects
None yet
Development

No branches or pull requests

1 participant