Search code examples
f#websharper

Is there any way to use JavaScript attribute by default?


I just want somehow to say "I want all methods in this project use [JavaScript]" Manually annotation every method is annoying


Solution

  • F# 3 lets you mark a module with the ReflectedDefinition attribute (aka [JavaScript] in WebSharper) which marks all the methods underneath.

    See More About F# 3.0 Language Features:

    (Speaking of uncommon attributes, in F# 3.0, the [< ReflectedDefinition >] attribute can now be placed on modules and type definitions, as a shorthand way to apply it to each individual member of the module/type.)