-
Notifications
You must be signed in to change notification settings - Fork 308
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
Function decorated with [<NamedParams>]
fails at runtime if all the arguments are optional and none are provided
#3480
Comments
Hello @Freymaurer, If you look at the generated JavaScript, the problem comes from this line When calling Indeed, without provide I would also like to ask you this question: What is your goal here for using The only usage that I know of But here, it seems like you are mixing it with some actual code and I don't know if this is an officially supported usage. In your case, can't you use the default F# method generation, without having the JavaScript modified to use destructuring patterns? |
I want to use // Without NamedParams
export const assay = ArcAssay.create();
export const assay2 = ArcAssay.create("Hello", void 0, "MyType"); // With NamedParams
export const assay = ArcAssay.create();
export const assay2 = ArcAssay.create({
id: "Hello",
measurementType: "MyType",
}); Both taken from Fable.Repl |
Ok, we will have to wait other maintainer opinion on this one.
|
[<NamedParams>]
fails at runtime if all the arguments are optional and none are provided
Update for the REPL. It does in fact not run correctly. I tried printing the created assays to the console and it does not work, unless i remove the |
Yes This is because, it generates Meaning that there are no object to desconstruct. If you provide at least 1 argument, then this works because the object will be initialised. |
Any new information on this? 😄 This would be a very nice option for libraries which should be usable on multiple languages. |
…ould take an empty object Fix #3480
In order to fix this issue, I had make changes in Fable.AST Does it means we need to ask for a re-release of Feliz.CompilerPlugins ? |
addition of
it now throws
I don't have a small repro just yet - will add a separate issue when I have it (seems to be related to using It fails even though in my Lesson to extract here is to keep coupling between types at minimum |
Description
Hey i am working on a library we want to offer for js as well as f#. So to improve JS syntax we wanted to use
![image](https://private-user-images.githubusercontent.com/39732517/249157979-976e4088-1b73-4783-87c8-a76aca69f0be.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzI0MTMsIm5iZiI6MTczOTM3MjExMywicGF0aCI6Ii8zOTczMjUxNy8yNDkxNTc5NzktOTc2ZTQwODgtMWI3My00NzgzLTg3YzgtYTc2YWNhNjlmMGJlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDE0NTUxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJmZWY3OWJmNmU0ZjNiYzlhYTcyZmUxYmIwOGE5NjhkNTBlZDg1OWRhNDg0ODE4M2UzZmRmMmM4MzJiZDQzODkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.OGCpCCqXKmqMIw90-h-FQJVULbdV23YINFTNYJHt3xI)
[<NamedParams>]
on members.I got a very strange error of:
.. when running my Fable.Mocha tests. To add to this:
[<NamedParams(fromIndex=0)>]
or[<NamedParams>]
it runs for Example 1.(fromIndex)
or not. So i would suspect the issue being?param
f# syntaxRepro code
Fable Repl
link
Example 1:
Library source code
Example 1:
https://github.com/nfdi4plants/ISADotNet/blob/ea4e1cefdceb8b0899f029409ee5ac4b003268f5/src/ISA/ISA/ArcTypes/ArcTable.fs#L166
Example 1:
https://github.com/nfdi4plants/ISADotNet/blob/ea4e1cefdceb8b0899f029409ee5ac4b003268f5/src/ISA/ISA/ArcTypes/ArcAssay.fs#L108
Expected and actual results
I would expect NamedParams to work in this case. Not sure where something is going wrong
Related information
dotnet fable --version
: 4.1.4The text was updated successfully, but these errors were encountered: