Skip to content

[react-native] Add PlatformConstants#51146

Merged
typescript-bot merged 3 commits intoDefinitelyTyped:masterfrom
jgonet:rn/platform-constants
Feb 13, 2021
Merged

[react-native] Add PlatformConstants#51146
typescript-bot merged 3 commits intoDefinitelyTyped:masterfrom
jgonet:rn/platform-constants

Conversation

@jgonet
Copy link
Copy Markdown
Contributor

@jgonet jgonet commented Feb 9, 2021

Description

The platform was lacking constants object so this PR adds them.

Checklist

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change.
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm test react-native. – fails with ../react/index.d.ts(38,22): error TS2307: Cannot find module 'csstype' or its corresponding type declarations.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://reactnative.dev/docs/platform#constants
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Feb 9, 2021

@jakub-gonet Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by a DT maintainer

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 51146,
  "author": "jakub-gonet",
  "headCommitOid": "f9844f0a49bd45b2338374630b07acb6f2b9fb86",
  "lastPushDate": "2021-02-12T21:41:21.000Z",
  "lastActivityDate": "2021-02-13T08:26:44.000Z",
  "maintainerBlessed": false,
  "mergeOfferDate": "2021-02-13T04:11:37.000Z",
  "mergeRequestDate": "2021-02-13T08:26:44.000Z",
  "mergeRequestUser": "jakub-gonet",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "react-native",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-native/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-native/test/index.tsx",
          "kind": "test"
        }
      ],
      "owners": [
        "alloy",
        "huhuanming",
        "iRoachie",
        "timwangdev",
        "kamal",
        "alexdunne",
        "swissmanu",
        "bm-software",
        "a-tarasyuk",
        "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",
        "akrger",
        "jeremybarbet",
        "ca057",
        "ds300",
        "natsathorn",
        "connectdotz",
        "TheWirv",
        "alexeymolchan",
        "alexbrazier",
        "kuasha420"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "rbuckton",
      "date": "2021-02-13T04:11:01.000Z",
      "isMaintainer": true
    },
    {
      "type": "stale",
      "reviewer": "ca057",
      "date": "2021-02-09T18:17:06.000Z",
      "abbrOid": "2cc4e05"
    }
  ],
  "ciResult": "pass"
}

@typescript-bot
Copy link
Copy Markdown
Contributor

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Feb 9, 2021
@typescript-bot
Copy link
Copy Markdown
Contributor

@jakub-gonet The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@jgonet
Copy link
Copy Markdown
Contributor Author

jgonet commented Feb 9, 2021

Not sure why CI is failing with this error:

Error: 1> node_modules/react-native-gesture-handler/dist/src/components/DrawerLayout.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/components/GestureButtons.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/components/GestureComponents.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/components/Swipeable.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/components/touchables/TouchableWithoutFeedback.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/gestureHandlerRootHOC.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/handlers/createNativeWrapper.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/handlers/gestureHandlers.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag

We have recently rewritten react-native-gesture-handler to TS and we use some types from RN. Should I update the config of RN types to enable interop with ES modules or we have some config problem on RNGH side?

@typescript-bot
Copy link
Copy Markdown
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

Comparison details 📊
master #51146 diff
Batch compilation
Memory usage (MiB) 112.9 112.4 -0.4%
Type count 34311 34323 0%
Assignability cache size 11827 11829 0%
Language service
Samples taken 2435 2461 +1%
Identifiers in tests 3136 3162 +1%
getCompletionsAtPosition
    Mean duration (ms) 420.7 419.4 -0.3%
    Mean CV 7.4% 7.5%
    Worst duration (ms) 738.5 711.1 -3.7%
    Worst identifier CellRendererComponent cellRenderer
getQuickInfoAtPosition
    Mean duration (ms) 421.9 421.0 -0.2%
    Mean CV 7.5% 7.8%
    Worst duration (ms) 722.5 666.8 -7.7%
    Worst identifier flattenStyle ref

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Feb 9, 2021
Co-authored-by: Christian Ost <hallo@christianost.de>
@typescript-bot typescript-bot added The CI failed When GH Actions fails and removed The CI failed When GH Actions fails labels Feb 9, 2021
@typescript-bot
Copy link
Copy Markdown
Contributor

@jakub-gonet The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot typescript-bot added the Owner Approved A listed owner of this package signed off on the pull request. label Feb 9, 2021
@alloy
Copy link
Copy Markdown
Collaborator

alloy commented Feb 10, 2021

We have recently rewritten react-native-gesture-handler to TS and we use some types from RN. Should I update the config of RN types to enable interop with ES modules or we have some config problem on RNGH side?

Looks like you might importing React like import React from "react" in RNGH instead of import * as React from "react"?

Either switch to the latter form or enable the esModuleInterop flag in your tsc config.

@jgonet
Copy link
Copy Markdown
Contributor Author

jgonet commented Feb 10, 2021

Looks like you might importing React like import React from "react" in RNGH instead of import * as React from "react"?

That's the case, thanks.

However, we have esModuleInterop set to true in the root tsconfig.json, so that surprised me a bit.

@typescript-bot typescript-bot removed Owner Approved A listed owner of this package signed off on the pull request. The CI failed When GH Actions fails labels Feb 12, 2021
@typescript-bot
Copy link
Copy Markdown
Contributor

@ca057 Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?

@jgonet
Copy link
Copy Markdown
Contributor Author

jgonet commented Feb 12, 2021

I released RNGH 1.10.1 with updated React imports and pushed an empty line here. CI should pass now.

@typescript-bot typescript-bot added Maintainer Approved Self Merge This PR can now be self-merged by the PR author or an owner labels Feb 13, 2021
@typescript-bot
Copy link
Copy Markdown
Contributor

@jakub-gonet Everything looks good here. Great job! I am ready to merge this PR (at f9844f0) on your behalf.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

(@alloy, @huhuanming, @iRoachie, @timwangdev, @kamal, @alexdunne, @swissmanu, @bm-software, @a-tarasyuk, @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, @akrger, @jeremybarbet, @ca057, @ds300, @natsathorn, @connectdotz, @TheWirv, @alexeymolchan, @alexbrazier, @kuasha420: you can do this too.)

@jgonet
Copy link
Copy Markdown
Contributor Author

jgonet commented Feb 13, 2021

Ready to merge

@typescript-bot typescript-bot merged commit 2796e83 into DefinitelyTyped:master Feb 13, 2021
@typescript-bot
Copy link
Copy Markdown
Contributor

I just published @types/react-native@0.63.49 to npm.

@jgonet jgonet deleted the rn/platform-constants branch February 13, 2021 13:43
ansu5555 pushed a commit to ansu5555/DefinitelyTyped that referenced this pull request Feb 19, 2021
… by @jakub-gonet

* Add PlatformConstants

* Use string union in uiMode types

Co-authored-by: Christian Ost <hallo@christianost.de>

* Remove empty line so CI can run

Co-authored-by: Christian Ost <hallo@christianost.de>
kaznovac pushed a commit to kaznovac/DefinitelyTyped that referenced this pull request Mar 2, 2021
… by @jakub-gonet

* Add PlatformConstants

* Use string union in uiMode types

Co-authored-by: Christian Ost <hallo@christianost.de>

* Remove empty line so CI can run

Co-authored-by: Christian Ost <hallo@christianost.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Critical package Maintainer Approved Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Self Merge This PR can now be self-merged by the PR author or an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants