-
Notifications
You must be signed in to change notification settings - Fork 301
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
Adding Babel types #1615
Adding Babel types #1615
Conversation
This is great @ncave! I'll try to have a deeper look later. But sorry, I don't understand your question, |
@alfonsogarciacaro Previously (in 1.x) the |
Ah, ok! I think probably the generic arguments can be extracted from the function type but let me check. |
a271ca6
to
5fb42f0
Compare
@ncave Sorry, forgot about this one! 😅 I haven't tested it, but I guess if you have the arg idents and the body you can get the generic parameter names for the annotation like this: let genParams =
let rec getGenParams = function
| Fable.GenericParam name -> [name]
| t -> t.Generics |> List.collect getGenParams
let types = (args |> List.map (fun (i: Fable.Ident) -> i.Type)) @ [body.Type]
([], types) ||> List.fold (fun acc t ->
acc @ (getGenParams t)) Does it help? |
@alfonsogarciacaro Any idea what can we do here for entities, as |
@ncave Probably you can use entityRefMaybeImported which is used to get the constructor function reference. But it doesn't work for the "primitive" types. We'll probably need a pattern matching like this one to cover all cases. |
98293a7
to
fc176b6
Compare
5b1047e
to
2609340
Compare
765ebd7
to
2d6dc56
Compare
d272c36
to
97980e1
Compare
dd1aeb3
to
027307b
Compare
Do you mean with the current implementation we can target the other compilers? I am asking because it is the reason why I wanted to make it explicit that we are generating typescript as an output. I didn't want to have I hope my intention is clear ^^ |
@MangelMaxime Yes, we should be able to target other compilers, but the name of the compiler option is not that important to spend much time over it. We can change it to be |
92d4935
to
957fc4b
Compare
6610697
to
0d0b6ca
Compare
Rebased to latest master. |
f332cd6
to
303ca59
Compare
@MangelMaxime As mentioned above, this functionality is hidden behind a flag, so it's fine to merge it in Fable v2.x. But if you prefer, we can merge this into a Fable v3.0 branch and publish it with a 3.0 prerelease tag (alpha/beta/next). |
@ncave Sorry for the delay, I got a bit crushed by work lately. I will include it in Fable 2 as you mentioned it is being a flag. I am also planning on making a pass on all Fable files to fix the indentation because some files, use 2 spaces,3 spaces, 4 spaces, or a mix of both. And, if we put your work in a separate branch it will make it even harder to fix the indentation problems^^. Also, with your current work on making us use |
@ncave I am not forgetting your PR. I am working on it while doing so I am also learning how Fable, fable-loader, fable-splitter and co works. So it will probably a bit more time for me to merge this PR. Sorry for the delay, I am exploring areas I never explored before in Fable and they are not the easiest to understand right now ^^ |
@MangelMaxime No worries, let me know if I can help with something (if I know the answer). |
@ncave Thank you. I think I am starting to understand how things work. I will probably create a diagram to help contribute and document the infra when re-working Fable website. Right now, I almost have a version of fable-splitter working with your branch: Almost, because I have a bug when copying the fable-library-ts source files. When fixed I will share my work so we can review it. I also saw a bug in the type generation when generating partial application: printfn "%s : %s" "maxime" "mangel" generates: (function () {
const clo1: (arg0: string, arg1: string) => void = toConsole(printf("%s : %s"));
const clo2: (arg0: string) => void = clo1("maxime");
clo2("mangel");
})(); I don't know if that's the correct definition but if I manually change the type to: const clo1: (arg0: string) => (arg1: string) => void = toConsole(printf("%s : %s")); then the error disappears. |
@MangelMaxime Yes, partial application is one of the few things that don't work properly yet. Producing types is still an experimental feature and needs to stay behind a flag. Another one is union/record/value type construction, still debatable if we should stick to object constructor functions, or generate minimal classes and use Still, it should be fine to merge it as is and improve as we go, but I'll leave it up to you. |
Also, this PR makes some steps towards resolving #1887. |
@ncave Ahah you were quicker than me to rebase your branch And here we go it is time to press the "red button" |
This is trying to bring back some of the Babel types from Fable 1.x
@alfonsogarciacaro A few questions, if you have the time to take a quick look:
AST.Fable.FunctionKind
andAST.Fable.ObjectMemberKind
?