Skip to content

Breaking change to React StatelessComponent definition #11929

Closed

Description

@janslow

Using [email protected] with strictNullChecks=true.

After updating from @types/[email protected] to 0.14.41 (PR #11912 from @donaldpipowitch), I've started getting errors on code which worked before:

For example,

$ tsc -p .
src/app/test.tsx(9,7): error TS2605: JSX element type 'ReactElement<any> | null' is not a constructor function for JSX elements.
  Type 'null' is not assignable to type 'ElementClass'.
import * as React from 'react';
import { StatelessComponent } from 'react';

const ElementA: StatelessComponent<any> = (props: {}) => (<div />);

function ElementB(props: {}): JSX.Element {
  return (
    <div>
      <ElementA />
    </div>
  );
}

It works fine if I use createElement(ElementA, {}) instead of the TSX form.

Activity

  1. changed the title [-]Stateless[/-] [+]Breaking change to React Stateless Components definition[/+] on Oct 12, 2016
  2. changed the title [-]Breaking change to React Stateless Components definition[/-] [+]Breaking change to React StatelessComponent definition[/+] on Oct 12, 2016
  3. donaldpipowitch commented on Oct 12, 2016

    @donaldpipowitch
    Contributor

    I'm sorry. I'll try to fix this.

  4. donaldpipowitch commented on Oct 12, 2016

    @donaldpipowitch
    Contributor

    Sorry, I think this could be a bug with TypeScript itself. I'll write a bug issue there and make a revertable pull request.

  5. added a commit that references this issue on Oct 12, 2016
    a70bf64
  6. janslow commented on Oct 12, 2016

    @janslow
    ContributorAuthor

    Thanks.

  7. janslow commented on Oct 21, 2016

    @janslow
    ContributorAuthor

    @donaldpipowitch, have you created a PR request for this? Thanks.

  8. donaldpipowitch commented on Oct 21, 2016

    @donaldpipowitch
    Contributor

    My PR was integrated into this PR #11935, but sadly no one has reviewed it so far :(

  9. donaldpipowitch commented on Nov 9, 2016

    @donaldpipowitch
    Contributor

    @janslow Should be fixed with #11935

    Could you test and close this issue, if it works?

  10. janslow commented on Nov 11, 2016

    @janslow
    ContributorAuthor

    Yep, that's fixed it now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions