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

Commit ff8459a

Browse files
committed
In untyped backend, don’t emit function to check the type of the imported component.
1 parent 122fb63 commit ff8459a

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,5 @@ import * as React from 'react';
66

77
import * as ReasonReact from 'reason-react/src/ReasonReact.js';
88

9-
// In case of type error, check the type of 'make' in 'ImportMyBanner.re' and the props of './MyBanner'.
10-
export function MyBannerTypeChecked(props) {
11-
return <MyBanner {...props}/>;
12-
}
13-
149
// Export 'make' early to allow circular import from the '.bs.js' file.
1510
export const make = function _(show, message, children) { return ReasonReact.wrapJsForReason(MyBanner, {show: show, message: (message == null ? message : {text:message[0]})}, children); };

src/EmitJs.re

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -402,33 +402,35 @@ let rec emitCodeItem =
402402
exportType,
403403
);
404404
let emitters =
405-
"("
406-
++ (
407-
"props"
408-
|> EmitTyp.ofType(
405+
config.language == Untyped ?
406+
emitters :
407+
"("
408+
++ (
409+
"props"
410+
|> EmitTyp.ofType(
411+
~config,
412+
~typeNameIsInterface,
413+
~typ=Ident(propsTypeName, []),
414+
)
415+
)
416+
++ ") {\n return <"
417+
++ componentName
418+
++ " {...props}/>;\n}"
419+
|> EmitTyp.emitExportFunction(
420+
~early=true,
421+
~emitters,
422+
~name=componentNameTypeChecked,
409423
~config,
410-
~typeNameIsInterface,
411-
~typ=Ident(propsTypeName, []),
412-
)
413-
)
414-
++ ") {\n return <"
415-
++ componentName
416-
++ " {...props}/>;\n}"
417-
|> EmitTyp.emitExportFunction(
418-
~early=true,
419-
~emitters,
420-
~name=componentNameTypeChecked,
421-
~config,
422-
~comment=
423-
"In case of type error, check the type of '"
424-
++ "make"
425-
++ "' in '"
426-
++ (fileName |> ModuleName.toString)
427-
++ ".re'"
428-
++ " and the props of '"
429-
++ (importPath |> ImportPath.toString)
430-
++ "'.",
431-
);
424+
~comment=
425+
"In case of type error, check the type of '"
426+
++ "make"
427+
++ "' in '"
428+
++ (fileName |> ModuleName.toString)
429+
++ ".re'"
430+
++ " and the props of '"
431+
++ (importPath |> ImportPath.toString)
432+
++ "'.",
433+
);
432434

433435
/* Wrap the component */
434436
let emitters =

0 commit comments

Comments
 (0)