@@ -308,18 +308,15 @@ and renderFunType ~config ~indent ~inFunType ~typeNameIsInterface ~typeVars
308
308
let typeToString ~config ~typeNameIsInterface type_ =
309
309
type_ |> renderType ~config ~type NameIsInterface ~in FunType:false
310
310
311
- let ofType ~config ~typeNameIsInterface ~type_ s =
312
- s ^ " : " ^ (type_ |> typeToString ~config ~type NameIsInterface)
313
-
314
311
let emitExportConst ~early ?(comment = " " ) ~config
315
312
?(docString = DocString. empty) ~emitters ~name ~type_ ~typeNameIsInterface
316
313
line =
314
+ let typeString = type_ |> typeToString ~config ~type NameIsInterface in
317
315
(match comment = " " with
318
316
| true -> comment
319
317
| false -> " // " ^ comment ^ " \n " )
320
- ^ DocString. render docString ^ " export const "
321
- ^ (name |> ofType ~config ~type NameIsInterface ~type_ )
322
- ^ " = " ^ line
318
+ ^ DocString. render docString ^ " export const " ^ name ^ " : " ^ typeString
319
+ ^ " = " ^ line ^ " as any;"
323
320
|> (match early with
324
321
| true -> Emitters. exportEarly
325
322
| false -> Emitters. export)
@@ -388,27 +385,20 @@ let emitRequire ~importedValueOrComponent ~early ~emitters ~(config : Config.t)
388
385
|> ImportPath. chopExtensionSafe (* for backward compatibility *)
389
386
| _ -> importPath
390
387
in
391
- match config.module_ with
392
- | ES6 when not importedValueOrComponent ->
393
- let moduleNameString = ModuleName. toString moduleName in
394
- (let es6ImportModule = moduleNameString ^ " __Es6Import" in
395
- " import * as " ^ es6ImportModule ^ " from '"
396
- ^ (importPath |> ImportPath. emit)
397
- ^ " ';\n " ^ " const " ^ moduleNameString ^ " : any = " ^ es6ImportModule ^ " ;" )
398
- |> (match early with
399
- | true -> Emitters. requireEarly
400
- | false -> Emitters. require)
401
- ~emitters
402
- | _ ->
403
- " const "
404
- ^ ModuleName. toString moduleName
405
- ^ " = require('"
406
- ^ (importPath |> ImportPath. emit)
407
- ^ " ');"
408
- |> (match early with
409
- | true -> Emitters. requireEarly
410
- | false -> Emitters. require)
411
- ~emitters
388
+ let moduleNameString = ModuleName. toString moduleName in
389
+ let importPathString = ImportPath. emit importPath in
390
+ let output =
391
+ match config.module_ with
392
+ | ES6 when not importedValueOrComponent ->
393
+ " import * as " ^ moduleNameString ^ " from '" ^ importPathString ^ " ';"
394
+ | _ ->
395
+ " const " ^ moduleNameString ^ " = require('" ^ importPathString ^ " ');"
396
+ in
397
+ output
398
+ |> (match early with
399
+ | true -> Emitters. requireEarly
400
+ | false -> Emitters. require)
401
+ ~emitters
412
402
413
403
let require ~early =
414
404
match early with
0 commit comments