Skip to content
This repository was archived by the owner on Nov 13, 2023. It is now read-only.

Commit c7a5413

Browse files
authored
Remove support for legacy components. (#551)
* Test: remove support for legacy components. * Remove code to import and export legacy components. * Dead code elimination. * Update Changes.md
1 parent 71fdbfb commit c7a5413

File tree

24 files changed

+164
-703
lines changed

24 files changed

+164
-703
lines changed

Changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# master
2+
- Remove support for legacy components.
23

34
# 3.50.0
45
- Flow: use `SyntheticMouseEvent` type for onClick.

examples/commonjs-react-example/src/ImportMyBanner.gen.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,28 @@
77
// $FlowExpectedError: Reason checked type sufficiently
88
type $any = any;
99

10-
// $FlowExpectedError: Reason checked type sufficiently
11-
const React = require('react');
12-
1310
// flowlint-next-line nonstrict-import:off
14-
const MyBanner = require('./MyBanner.component');
15-
16-
// $FlowExpectedError: Reason checked type sufficiently
17-
const ReasonReact = require('reason-react/src/ReasonReact.js');
11+
const $$MyBanner = require('./MyBanner.component');
1812

19-
export type Props = {| +show: boolean, +Message: ?string |};
20-
21-
// In case of type error, check the type of 'make' in 'ImportMyBanner.re' and the props of './MyBanner.component'.
22-
function MyBannerTypeChecked(props: Props): React$Node {
23-
return <MyBanner {...props}/>;
24-
};
25-
exports.MyBannerTypeChecked = MyBannerTypeChecked
13+
// In case of type error, check the type of 'make' in 'ImportMyBanner.re' and './MyBanner.component'.
14+
const makeTypeChecked: <a>({| +show: boolean, +Message: ?string |}, a) => ReasonReact_component<ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_actionless> = $$MyBanner.make;;
15+
exports.makeTypeChecked = makeTypeChecked
2616

2717
// Export 'make' early to allow circular import from the '.bs.js' file.
28-
const make: mixed = function (show: $any, Message: $any, children: $any) { return ReasonReact.wrapJsForReason(MyBanner, {show: show, Message: Message}, children); };;
18+
const make: mixed = function <a>(Argshow: $any, ArgMessage: $any, Arg2: $any) {
19+
const result = makeTypeChecked({show:Argshow, Message:ArgMessage}, Arg2);
20+
return result
21+
};;
2922
exports.make = make
23+
24+
// flowlint-next-line nonstrict-import:off
25+
import type {actionless as ReasonReact_actionless} from '../src/shims/ReactShim.shim';
26+
27+
// flowlint-next-line nonstrict-import:off
28+
import type {component as ReasonReact_component} from '../src/shims/ReactShim.shim';
29+
30+
// flowlint-next-line nonstrict-import:off
31+
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../src/shims/ReactShim.shim';
32+
33+
// flowlint-next-line nonstrict-import:off
34+
import type {stateless as ReasonReact_stateless} from '../src/shims/ReactShim.shim';

examples/flow-react-example/src/AutoAnnotate.gen.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@
44
* @nolint
55
*/
66
/* eslint-disable */
7+
// $FlowExpectedError: Reason checked type sufficiently
8+
type $any = any;
79

810
// $FlowExpectedError: Reason checked type sufficiently
911
import * as Curry from 'rescript/lib/es6/curry.js';
1012

1113
// $FlowExpectedError: Reason checked type sufficiently
1214
import * as AutoAnnotateBS from './AutoAnnotate.bs';
1315

14-
// $FlowExpectedError: Reason checked type sufficiently
15-
import * as ReasonReact from 'reason-react/src/ReasonReact.js';
16+
// flowlint-next-line nonstrict-import:off
17+
import type {actionless as ReasonReact_actionless} from '../src/shims/ReactShim.shim';
18+
19+
// flowlint-next-line nonstrict-import:off
20+
import type {componentSpec as ReasonReact_componentSpec} from '../src/shims/ReactShim.shim';
21+
22+
// flowlint-next-line nonstrict-import:off
23+
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../src/shims/ReactShim.shim';
24+
25+
// flowlint-next-line nonstrict-import:off
26+
import type {stateless as ReasonReact_stateless} from '../src/shims/ReactShim.shim';
1627

1728
export type variant = {| tag: "R", value: number |};
1829

@@ -34,12 +45,7 @@ export type r6 = {| +r6: number |};
3445

3546
export const useR5: (r5) => r5 = AutoAnnotateBS.useR5;
3647

37-
export type Props = {| +r6: r6, +children?: mixed |};
38-
39-
export const component: React$ComponentType<Props> = ReasonReact.wrapReasonForJs(
40-
AutoAnnotateBS.component,
41-
(function _(jsProps: Props) {
42-
return Curry._2(AutoAnnotateBS.make, jsProps.r6, jsProps.children);
43-
}));
44-
45-
export default component;
48+
export const make: <T1>({| +r6: r6 |}, T1) => ReasonReact_componentSpec<ReasonReact_stateless,ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_noRetainedProps,ReasonReact_actionless> = function <T1>(Arg1: $any, Arg2: $any) {
49+
const result = Curry._2(AutoAnnotateBS.make, Arg1.r6, Arg2);
50+
return result
51+
};

examples/flow-react-example/src/TestImport.gen.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ import {ValueStartingWithUpperCaseLetter as valueStartingWithUpperCaseLetterNotC
2020
import {default as defaultValueNotChecked} from './exportNestedValues';
2121

2222
// flowlint-next-line nonstrict-import:off
23-
import {TopLevelClass as TopLevelClass} from './interop/MyBanner.component';
24-
25-
// $FlowExpectedError: Reason checked type sufficiently
26-
import * as React from 'react';
27-
28-
// $FlowExpectedError: Reason checked type sufficiently
29-
import * as ReasonReact from 'reason-react/src/ReasonReact.js';
23+
import {TopLevelClass as makeNotChecked} from './interop/MyBanner.component';
3024

3125
// In case of type error, check the type of 'innerStuffContents' in 'TestImport.re' and './exportNestedValues'.
3226
export const innerStuffContentsTypeChecked: {| +x: number |} = innerStuffContentsNotChecked.MiddleLevelElements.stuff.InnerStuff.innerStuffContents;
@@ -52,14 +46,25 @@ export const defaultValueTypeChecked: number = defaultValueNotChecked;
5246
// Export 'defaultValue' early to allow circular import from the '.bs.js' file.
5347
export const defaultValue: mixed = defaultValueTypeChecked;
5448

55-
export type Props = {| +show: boolean, +Message: ?string |};
56-
57-
// In case of type error, check the type of 'make' in 'TestImport.re' and the props of './interop/MyBanner.component'.
58-
export function MyBannerInternalTypeChecked(props: Props): React$Node {
59-
return <TopLevelClass.MiddleLevelElements.MyBannerInternal {...props}/>;
60-
}
49+
// In case of type error, check the type of 'make' in 'TestImport.re' and './interop/MyBanner.component'.
50+
export const makeTypeChecked: <a>({| +show: boolean, +Message: ?string |}, a) => ReasonReact_component<ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_actionless> = makeNotChecked.MiddleLevelElements.MyBannerInternal;
6151

6252
// Export 'make' early to allow circular import from the '.bs.js' file.
63-
export const make: mixed = function (show: $any, Message: $any, children: $any) { return ReasonReact.wrapJsForReason(TopLevelClass.MiddleLevelElements.MyBannerInternal, {show: show, Message: Message}, children); };
53+
export const make: mixed = function <a>(Argshow: $any, ArgMessage: $any, Arg2: $any) {
54+
const result = makeTypeChecked({show:Argshow, Message:ArgMessage}, Arg2);
55+
return result
56+
};
57+
58+
// flowlint-next-line nonstrict-import:off
59+
import type {actionless as ReasonReact_actionless} from '../src/shims/ReactShim.shim';
60+
61+
// flowlint-next-line nonstrict-import:off
62+
import type {component as ReasonReact_component} from '../src/shims/ReactShim.shim';
63+
64+
// flowlint-next-line nonstrict-import:off
65+
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../src/shims/ReactShim.shim';
66+
67+
// flowlint-next-line nonstrict-import:off
68+
import type {stateless as ReasonReact_stateless} from '../src/shims/ReactShim.shim';
6469

6570
export type message = {| +text: string |};

examples/flow-react-example/src/components/Navigator.gen.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,28 @@
44
* @nolint
55
*/
66
/* eslint-disable */
7+
// $FlowExpectedError: Reason checked type sufficiently
8+
type $any = any;
79

810
// $FlowExpectedError: Reason checked type sufficiently
911
import * as Curry from 'rescript/lib/es6/curry.js';
1012

1113
// $FlowExpectedError: Reason checked type sufficiently
1214
import * as NavigatorBS from './Navigator.bs';
1315

14-
// $FlowExpectedError: Reason checked type sufficiently
15-
import * as ReasonReact from 'reason-react/src/ReasonReact.js';
16+
// flowlint-next-line nonstrict-import:off
17+
import type {actionless as ReasonReact_actionless} from '../../src/shims/ReactShim.shim';
18+
19+
// flowlint-next-line nonstrict-import:off
20+
import type {componentSpec as ReasonReact_componentSpec} from '../../src/shims/ReactShim.shim';
1621

17-
export type Props = {|
18-
+history: mixed,
19-
+match: mixed,
20-
+children?: mixed
21-
|};
22+
// flowlint-next-line nonstrict-import:off
23+
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../../src/shims/ReactShim.shim';
2224

23-
export const component: React$ComponentType<Props> = ReasonReact.wrapReasonForJs(
24-
NavigatorBS.component,
25-
(function _(jsProps: Props) {
26-
return Curry._3(NavigatorBS.make, jsProps.history, jsProps.match, jsProps.children);
27-
}));
25+
// flowlint-next-line nonstrict-import:off
26+
import type {stateless as ReasonReact_stateless} from '../../src/shims/ReactShim.shim';
2827

29-
export default component;
28+
export const make: <T1,T2,T3>({| +history: T1, +match: T2 |}, T3) => ReasonReact_componentSpec<ReasonReact_stateless,ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_noRetainedProps,ReasonReact_actionless> = function <T1,T2,T3>(Arg1: $any, Arg2: $any) {
29+
const result = Curry._3(NavigatorBS.make, Arg1.history, Arg1.match, Arg2);
30+
return result
31+
};

examples/flow-react-example/src/components/RenameProps.gen.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ type $any = any;
1010
// $FlowExpectedError: Reason checked type sufficiently
1111
import * as Curry from 'rescript/lib/es6/curry.js';
1212

13-
// $FlowExpectedError: Reason checked type sufficiently
14-
import * as ReasonReact from 'reason-react/src/ReasonReact.js';
15-
1613
// $FlowExpectedError: Reason checked type sufficiently
1714
import * as RenamePropsBS from './RenameProps.bs';
1815

16+
// flowlint-next-line nonstrict-import:off
17+
import type {actionless as ReasonReact_actionless} from '../../src/shims/ReactShim.shim';
18+
19+
// flowlint-next-line nonstrict-import:off
20+
import type {componentSpec as ReasonReact_componentSpec} from '../../src/shims/ReactShim.shim';
21+
22+
// flowlint-next-line nonstrict-import:off
23+
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../../src/shims/ReactShim.shim';
24+
25+
// flowlint-next-line nonstrict-import:off
26+
import type {stateless as ReasonReact_stateless} from '../../src/shims/ReactShim.shim';
27+
1928
export type functionTypeWithGenTypeAs = ({| +type: string, +$number: number |}) => number;
2029

2130
export const functionWithGenTypeAs: ({|
@@ -27,20 +36,14 @@ export const functionWithGenTypeAs: ({|
2736
return result
2837
};
2938

30-
export type Props = {|
39+
export const make: <T1>({|
3140
+firstNameArgumentCantBeRenamed: string,
3241
+type: string,
33-
+$$number: number,
34-
+children?: mixed
35-
|};
36-
37-
export const component: React$ComponentType<Props> = ReasonReact.wrapReasonForJs(
38-
RenamePropsBS.component,
39-
(function _(jsProps: Props) {
40-
return Curry._4(RenamePropsBS.make, jsProps.firstNameArgumentCantBeRenamed, jsProps.type, jsProps.$$number, jsProps.children);
41-
}));
42-
43-
export default component;
42+
+$$number: number
43+
|}, T1) => ReasonReact_componentSpec<ReasonReact_stateless,ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_noRetainedProps,ReasonReact_actionless> = function <T1>(Arg1: $any, Arg2: $any) {
44+
const result = Curry._4(RenamePropsBS.make, Arg1.firstNameArgumentCantBeRenamed, Arg1.type, Arg1.$$number, Arg2);
45+
return result
46+
};
4447

4548
export const firstIsIgnored: ({| +Ignored: number |}) => number = function (Arg1: $any) {
4649
const result = RenamePropsBS.firstIsIgnored(Arg1.Ignored);

examples/flow-react-example/src/interop/ImportMyBanner.gen.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,25 @@
88
type $any = any;
99

1010
// flowlint-next-line nonstrict-import:off
11-
import MyBanner from './MyBanner.component';
11+
import {make as makeNotChecked} from './MyBanner.component';
1212

13-
// $FlowExpectedError: Reason checked type sufficiently
14-
import * as React from 'react';
13+
// In case of type error, check the type of 'make' in 'ImportMyBanner.re' and './MyBanner.component'.
14+
export const makeTypeChecked: <a>({| +show: boolean, +Message: ?string |}, a) => ReasonReact_component<ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_actionless> = makeNotChecked;
1515

16-
// $FlowExpectedError: Reason checked type sufficiently
17-
import * as ReasonReact from 'reason-react/src/ReasonReact.js';
16+
// Export 'make' early to allow circular import from the '.bs.js' file.
17+
export const make: mixed = function <a>(Argshow: $any, ArgMessage: $any, Arg2: $any) {
18+
const result = makeTypeChecked({show:Argshow, Message:ArgMessage}, Arg2);
19+
return result
20+
};
1821

19-
export type Props = {| +show: boolean, +Message: ?string |};
22+
// flowlint-next-line nonstrict-import:off
23+
import type {actionless as ReasonReact_actionless} from '../../src/shims/ReactShim.shim';
2024

21-
// In case of type error, check the type of 'make' in 'ImportMyBanner.re' and the props of './MyBanner.component'.
22-
export function MyBannerTypeChecked(props: Props): React$Node {
23-
return <MyBanner {...props}/>;
24-
}
25+
// flowlint-next-line nonstrict-import:off
26+
import type {component as ReasonReact_component} from '../../src/shims/ReactShim.shim';
2527

26-
// Export 'make' early to allow circular import from the '.bs.js' file.
27-
export const make: mixed = function (show: $any, Message: $any, children: $any) { return ReasonReact.wrapJsForReason(MyBanner, {show: show, Message: Message}, children); };
28+
// flowlint-next-line nonstrict-import:off
29+
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../../src/shims/ReactShim.shim';
30+
31+
// flowlint-next-line nonstrict-import:off
32+
import type {stateless as ReasonReact_stateless} from '../../src/shims/ReactShim.shim';

examples/typescript-react-example/src/ImportMyBanner.gen.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
/* eslint-disable import/first */
33

44

5-
import MyBanner from './MyBanner';
5+
import {make as makeNotChecked} from './MyBanner';
66

7-
import * as React from 'react';
7+
// In case of type error, check the type of 'make' in 'ImportMyBanner.re' and './MyBanner'.
8+
export const makeTypeChecked: <a>(_1:{ readonly show: boolean; readonly message?: message }, _2:a) => ReasonReact_component<ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_actionless> = makeNotChecked;
89

9-
// @ts-ignore: Implicit any on import
10-
import * as ReasonReact__Es6Import from 'reason-react/src/ReasonReact.js';
11-
const ReasonReact: any = ReasonReact__Es6Import;
10+
// Export 'make' early to allow circular import from the '.bs.js' file.
11+
export const make: unknown = function <a>(Argshow: any, Argmessage: any, Arg2: any) {
12+
const result = makeTypeChecked({show:Argshow, message:Argmessage}, Arg2);
13+
return result
14+
} as <a>(_1:{ readonly show: boolean; readonly message?: message }, _2:a) => ReasonReact_component<ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_actionless>;
1215

13-
// tslint:disable-next-line:interface-over-type-literal
14-
export type Props = { readonly show: boolean; readonly message?: message };
16+
import type {actionless as ReasonReact_actionless} from '../src/shims/ReactShim.shim';
1517

16-
// In case of type error, check the type of 'make' in 'ImportMyBanner.re' and the props of './MyBanner'.
17-
export function MyBannerTypeChecked(props: Props): JSX.Element {
18-
return <MyBanner {...props}/>;
19-
}
18+
import type {component as ReasonReact_component} from '../src/shims/ReactShim.shim';
2019

21-
// Export 'make' early to allow circular import from the '.bs.js' file.
22-
export const make: unknown = function (show: any, message: any, children: any) { return ReasonReact.wrapJsForReason(MyBanner, {show: show, message: message}, children); };
20+
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../src/shims/ReactShim.shim';
21+
22+
import type {stateless as ReasonReact_stateless} from '../src/shims/ReactShim.shim';
2323

2424
// tslint:disable-next-line:interface-over-type-literal
2525
export type message = { readonly text: string };

examples/typescript-react-example/src/TestImport.gen.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,10 @@ import {ValueStartingWithUpperCaseLetter as valueStartingWithUpperCaseLetterNotC
1010

1111
import {default as defaultValueNotChecked} from './exportNestedValues';
1212

13-
import {TopLevelClass as TopLevelClass} from './MyBanner';
13+
import {TopLevelClass as makeNotChecked} from './MyBanner';
1414

1515
import {default as defaultValue2NotChecked} from './exportNestedValues';
1616

17-
import * as React from 'react';
18-
19-
// @ts-ignore: Implicit any on import
20-
import * as ReasonReact__Es6Import from 'reason-react/src/ReasonReact.js';
21-
const ReasonReact: any = ReasonReact__Es6Import;
22-
2317
// In case of type error, check the type of 'innerStuffContents' in 'TestImport.re' and './exportNestedValues'.
2418
export const innerStuffContentsTypeChecked: { readonly x: number } = innerStuffContentsNotChecked.MiddleLevelElements.stuff.InnerStuff.innerStuffContents;
2519

@@ -44,22 +38,28 @@ export const defaultValueTypeChecked: number = defaultValueNotChecked;
4438
// Export 'defaultValue' early to allow circular import from the '.bs.js' file.
4539
export const defaultValue: unknown = defaultValueTypeChecked as number;
4640

47-
// tslint:disable-next-line:interface-over-type-literal
48-
export type Props = { readonly show: boolean; readonly message?: message };
49-
50-
// In case of type error, check the type of 'make' in 'TestImport.re' and the props of './MyBanner'.
51-
export function MyBannerInternalTypeChecked(props: Props): JSX.Element {
52-
return <TopLevelClass.MiddleLevelElements.MyBannerInternal {...props}/>;
53-
}
41+
// In case of type error, check the type of 'make' in 'TestImport.re' and './MyBanner'.
42+
export const makeTypeChecked: <a>(_1:{ readonly show: boolean; readonly message?: message }, _2:a) => ReasonReact_component<ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_actionless> = makeNotChecked.MiddleLevelElements.MyBannerInternal;
5443

5544
// Export 'make' early to allow circular import from the '.bs.js' file.
56-
export const make: unknown = function (show: any, message: any, children: any) { return ReasonReact.wrapJsForReason(TopLevelClass.MiddleLevelElements.MyBannerInternal, {show: show, message: message}, children); };
45+
export const make: unknown = function <a>(Argshow: any, Argmessage: any, Arg2: any) {
46+
const result = makeTypeChecked({show:Argshow, message:Argmessage}, Arg2);
47+
return result
48+
} as <a>(_1:{ readonly show: boolean; readonly message?: message }, _2:a) => ReasonReact_component<ReasonReact_stateless,ReasonReact_noRetainedProps,ReasonReact_actionless>;
5749

5850
// In case of type error, check the type of 'defaultValue2' in 'TestImport.re' and './exportNestedValues'.
5951
export const defaultValue2TypeChecked: number = defaultValue2NotChecked;
6052

6153
// Export 'defaultValue2' early to allow circular import from the '.bs.js' file.
6254
export const defaultValue2: unknown = defaultValue2TypeChecked as number;
6355

56+
import type {actionless as ReasonReact_actionless} from '../src/shims/ReactShim.shim';
57+
58+
import type {component as ReasonReact_component} from '../src/shims/ReactShim.shim';
59+
60+
import type {noRetainedProps as ReasonReact_noRetainedProps} from '../src/shims/ReactShim.shim';
61+
62+
import type {stateless as ReasonReact_stateless} from '../src/shims/ReactShim.shim';
63+
6464
// tslint:disable-next-line:interface-over-type-literal
6565
export type message = { readonly text: string };

examples/untyped-react-example/src/ImportMyBanner.gen.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
*/
55
/* eslint-disable */
66

7-
import MyBanner from './MyBanner';
7+
import {make as makeNotChecked} from './MyBanner';
88

9-
import * as React from 'react';
10-
11-
import * as ReasonReact from 'reason-react/src/ReasonReact.js';
9+
// In case of type error, check the type of 'make' in 'ImportMyBanner.re' and './MyBanner'.
10+
export const makeTypeChecked = makeNotChecked;
1211

1312
// Export 'make' early to allow circular import from the '.bs.js' file.
14-
export const make = function (show, message, children) { return ReasonReact.wrapJsForReason(MyBanner, {show: show, message: message}, children); };
13+
export const make = function (Argshow, Argmessage, Arg2) {
14+
const result = makeTypeChecked({show:Argshow, message:Argmessage}, Arg2);
15+
return result
16+
};

0 commit comments

Comments
 (0)