Skip to content

[react-native] Correctly extend ViewProps in PressableProps#58292

Merged
sandersn merged 1 commit into
DefinitelyTyped:masterfrom
eps1lon:fix/react-fragment/react-native
Jan 21, 2022
Merged

[react-native] Correctly extend ViewProps in PressableProps#58292
sandersn merged 1 commit into
DefinitelyTyped:masterfrom
eps1lon:fix/react-fragment/react-native

Conversation

@eps1lon
Copy link
Copy Markdown
Collaborator

@eps1lon eps1lon commented Jan 18, 2022

We plan to remove {} from ReactFragment since it's not actually an allowed type for children of host components (e.g. <div>{{}}</div> would throw at runtime) (see #56026 for previous attempts).

The changes all fix intersections of ReactNode with render-props. This only passed because render-props were assignable to {}.

This change is required to pass #56210

@eps1lon eps1lon marked this pull request as ready for review January 18, 2022 19:48
@eps1lon eps1lon requested a review from alloy as a code owner January 18, 2022 19:49
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Jan 18, 2022

@eps1lon Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

This PR can be merged once it's reviewed by a DT maintainer.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • 🕐 Only a DT maintainer can approve changes without tests

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 58292,
  "author": "eps1lon",
  "headCommitOid": "130afae7963af7492d0224f97226479cfcdb7d0c",
  "mergeBaseOid": "c609479376c92be2991c6d072a70201f7e225047",
  "lastPushDate": "2022-01-18T19:28:40.000Z",
  "lastActivityDate": "2022-01-20T16:08:20.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Popular",
  "pkgInfo": [
    {
      "name": "react-native",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-native/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-native/v0.63/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-native/v0.64/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-native/v0.65/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "alloy",
        "huhuanming",
        "iRoachie",
        "timwangdev",
        "kamal",
        "alexdunne",
        "swissmanu",
        "bm-software",
        "mvdam",
        "esemesek",
        "mrnickel",
        "souvik-ghosh",
        "nossbigg",
        "saranshkataria",
        "tykus160",
        "jakebloom",
        "ceyhun",
        "mcmar",
        "theohdv",
        "TheSavior",
        "romain-faust",
        "bebebebebe",
        "Naturalclar",
        "chinesedfan",
        "vtolochk",
        "SychevSP",
        "RageBill",
        "sasurau4",
        "256hz",
        "doumart",
        "drmas",
        "jeremybarbet",
        "ca057",
        "ds300",
        "natsathorn",
        "connectdotz",
        "TheWirv",
        "alexeymolchan",
        "alexbrazier",
        "kuasha420",
        "phvillegas",
        "eps1lon"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "ca057",
      "date": "2022-01-19T18:44:41.000Z",
      "isMaintainer": false
    }
  ],
  "mainBotCommentID": 1015778999,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Author is Owner The author of this PR is a listed owner of the package. Untested Change This PR does not touch tests labels Jan 18, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

@ca057 ca057 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I slowly get what this is about looking at related PRs, but I can’t match it to your PR description:

The changes all fix intersections of ReactNode with render-props. This only passed because render-props were assignable to {}.

Can you give me a hint to better connect this line to your PR?

But thanks for your work of fixing all these packages!

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Jan 19, 2022
@eps1lon
Copy link
Copy Markdown
Collaborator Author

eps1lon commented Jan 19, 2022

Can you give me a hint to better connect this line to your PR?

I accidentally used "intersection" when I meant "extending". An intersection would work. But extending doesn't.

Does this example illustrate the issue better?

interface OldViewProps {
  // `{}` will be removed in React 18 types
  children: string | {};

}

interface OldPressableProps extends OldViewProps {
  children: () => string;
}


interface NewViewProps {
  children: string;
}

interface NewPressableProps extends NewViewProps {
  children: () => string;
}

Playground Link

@ca057
Copy link
Copy Markdown
Contributor

ca057 commented Jan 20, 2022

Thanks for the additional explanation, now it makes sense :)

@sandersn sandersn merged commit 924e527 into DefinitelyTyped:master Jan 21, 2022
@eps1lon eps1lon deleted the fix/react-fragment/react-native branch January 22, 2022 16:47
martin-badin pushed a commit to martin-badin/DefinitelyTyped that referenced this pull request Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author is Owner The author of this PR is a listed owner of the package. Owner Approved A listed owner of this package signed off on the pull request. Popular package This PR affects a popular package (as counted by NPM download counts). Untested Change This PR does not touch tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants