Skip to content

Commit

Permalink
React module exports should not be an exact object
Browse files Browse the repository at this point in the history
Summary:
The exports of the `react` module should not be an exact object, as the exports can have unknown properties.

E.g. experimental features: https://www.internalfb.com/code/search?q=filepath%3Ahtml%2Fjs%2F%7Chtml%2Fintern%2Fjs%2F%7Chtml%2Fshared%2F%20repo%3Awww%20React.unstable_&hide_uninteresting=false&hide_tests=false

This doesn't currently matter much, but is technically more accurate and might have an effect with some future changes I might make

Changelog: [minor] React default exports are now inexact, as technically this can include unknown properties (experimental features)

Reviewed By: samwgoldman

Differential Revision: D34337501

fbshipit-source-id: e3172a2d18993745bd4bed8161b239b226a796ad
  • Loading branch information
gkz authored and facebook-github-bot committed Feb 18, 2022
1 parent de8eefc commit 7136570
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 116 deletions.
5 changes: 3 additions & 2 deletions lib/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ declare module react {
timeoutMs: number,
|};

declare export default {|
declare export default {
+DOM: typeof DOM,
+PropTypes: typeof PropTypes,
+version: typeof version,
Expand Down Expand Up @@ -460,7 +460,8 @@ declare module react {
+useTransition: typeof useTransition,
+useDeferredValue: typeof useDeferredValue,
+startTransition: typeof startTransition,
|};
...
};
}

// TODO Delete this once https://github.com/facebook/react/pull/3031 lands
Expand Down
4 changes: 2 additions & 2 deletions tests/automatic_require_default/automatic_require_default.exp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Cannot get `React.NotAType` because property `NotAType` is missing in module `re
^^^^^^^^

References:
<BUILTINS>/react.js:469:27
469| declare module.exports: $Exports<'react'>;
<BUILTINS>/react.js:470:27
470| declare module.exports: $Exports<'react'>;
^^^^^^^^^^^^^^^^^ [1]


Expand Down
12 changes: 6 additions & 6 deletions tests/new_react/new_react.exp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,13 +1319,13 @@ Cannot get `React.PropTypes.string.inRequired` because property `inRequired` (di
^^^^^^^^^^

References:
<BUILTINS>/react.js:478:39
<BUILTINS>/react.js:479:39
v
478| type ReactPropsChainableTypeChecker = {
479| (props: any, propName: string, componentName: string, href?: string): ?Error,
480| isRequired: ReactPropsCheckType,
481| ...
482| };
479| type ReactPropsChainableTypeChecker = {
480| (props: any, propName: string, componentName: string, href?: string): ?Error,
481| isRequired: ReactPropsCheckType,
482| ...
483| };
^ [1]


Expand Down

0 comments on commit 7136570

Please sign in to comment.