-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import followed by a comments should be moved to the top of the generated file #3774
Comments
Hello, Fable always try to put import statement at the top of the file. The line that you liked is the exposed API, you will need to look into For example, this API is probably handled here: Fable/src/Fable.Transforms/Replacements.fs Lines 1027 to 1032 in c287b15
But I am not sure yet where Fable does the re-ordering. Could you please explain what is your request with this issue? Because I don't understand your request with the current title and description. Is the request that import statement with a trailing comment should also be moved up too? |
Yes, sorry, @MangelMaxime my question was not clear. import JSZip from "jszip"; not import {JSZip} from "jszip"; I tried all attributes form the docs : REPL [<ImportMember(".." , "...")>] ( this should compile but doesn't ! Are the docs wrong? ) Is including it in a |
There is indeed a typo in the documentation regarding Fable/src/Fable.Core/Fable.Core.Types.fs Lines 60 to 62 in c287b15
But it would still not generate what you want as it would generate In JavaScript To proves that you can try to run: import JSZip from 'jszip';
import { default as bar } from 'jszip';
console.log(JSZip);
console.log(bar); and you will see the same output for both
So using: [<ImportDefault("jszip")>]
type JSZip() = class end
//or
let jsZip1 = import "default" "jszip"
let jsZip2 = importDefault "jszip" are equivalent. You don't need |
Thanks, I found that only open Fable.Core.JsInterop
do
import "default as JSZip" "jszip" yields import JSZip from "jszip"; |
I still leave this issue open because I think import statement with a trailing comment should not behave differently. |
I did not know that 'emitJsStatement' will extract imports:
but if it has a comment, it won't:
see REPL
where is this implemented? I only found this
Fable/src/Fable.Core/Fable.Core.JsInterop.fs
Line 48 in c287b15
The text was updated successfully, but these errors were encountered: