Skip to content

Exporting POJOs for consumption in JS project / "Emit" attribute query #2937

Answered by alfonsogarciacaro
drk-mtr asked this question in Q&A
Discussion options

You must be logged in to vote

Hmm, this is tricky because there's no mechanism in F# to re-export types (only type aliases but these are erased in the generated code). In this case, I'd probably just write the index.js file directly in JS, unless there's a lot of other code that you want to write directly in F#. If you still need to write it in F# maybe you can use import expressions instead of attributes, which also generate a export if the member is public. Also, you can use the ${outDir} macro so you don't need to type the output directory manually in the import. Something like this should work:

open Fable.Core.JsInterop

let UserDto: JsConstructor = importMember "${outDir}/user.dto.js"

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@drk-mtr
Comment options

Answer selected by drk-mtr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants