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

Commit

Permalink
In TS, emit import react when a react component is exported.
Browse files Browse the repository at this point in the history
Fixes #342
  • Loading branch information
cristianoc committed Dec 24, 2019
1 parent 00f753d commit 2d4b678
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/* eslint-disable import/first */


import * as React from 'react';

// tslint:disable-next-line:no-var-requires
const ExportWithRenameBS = require('./ExportWithRename.bs');

Expand Down
10 changes: 5 additions & 5 deletions src/EmitJs.re
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,9 @@ let rec emitCodeItem =
typeVars,
resolvedTypeName,
};
if (config.language == TypeScript) {
config.emitImportReact = true;
};
emitExportType(
~emitters,
~config,
Expand Down Expand Up @@ -1106,9 +1109,7 @@ let getAnnotatedTypedDeclarations = (~annotatedSet, typeDeclarations) =>
};
})
|> List.filter(
(
{exportFromTypeDeclaration: {annotation}}: CodeItem.typeDeclaration,
) =>
({exportFromTypeDeclaration: {annotation}}: CodeItem.typeDeclaration) =>
annotation != NoGenType
);

Expand Down Expand Up @@ -1160,8 +1161,7 @@ let propagateAnnotationToSubTypes =
retType |> visit;
| GroupOfLabeledArgs(fields)
| Object(_, fields)
| Record(fields) =>
fields |> List.iter(({type_}) => type_ |> visit)
| Record(fields) => fields |> List.iter(({type_}) => type_ |> visit)
| Option(t)
| Null(t)
| Nullable(t)
Expand Down

0 comments on commit 2d4b678

Please sign in to comment.