Saltarelle / SaltarelleCompiler

C# to JavaScript compiler – Now http://bridge.net
http://saltarelle-compiler.com
Other
297 stars 74 forks source link

An option to prevent passing not specifed optional arguments? #376

Open n9 opened 9 years ago

n9 commented 9 years ago

Sometimes, JavaScript libraries use arguments.length variable to access arguments passed to a function. Saltarelle substitutes not specified optional arguments with their default values. This is good for C# code, however it is not convenient for JavaScript interop scenarios, as one mentioned.

Is there an attribute that could be specified on a method or a delegate that optional arguments are not passed or passed as undefined?

Currently, the only way I know is to create multiple overloads of a same function.

n9 commented 9 years ago

It is also not possible to use Script.Undefined instead of null, since it is not a compile-time constant.

erik-kallen commented 9 years ago

In v3 there will be an attribute [OmitArgumentsFrom(n)] which can be used for this purpose.