dotnet-websharper / core

WebSharper - Full-stack, functional, reactive web apps and microservices in F# and C#
https://websharper.com
Apache License 2.0
594 stars 52 forks source link

Give specific error on not finding proxies for decimal/bigint/Complex #962

Open Jand42 opened 6 years ago

Jand42 commented 6 years ago

These are the 3 numeric types that are proxied outside of WebSharper.Main: by WebSharper.MathJS which is in a separate nuget package. Compiler could give error telling to include that package reference when using those types instead of the usual "not found in JavaScript compilation" error.

granicz commented 5 years ago

I am getting this when trying to use a decimal in an RPC:

WebSharper.Main.js?h=1127374076:269 Uncaught TypeError: Cannot read property 'CreateDecimalBits' of undefined
at decode (WebSharper.Main.js?h=1127374076:269)
at Object.Arrays.map (WebSharper.Main.js?h=1127374076:2364)
at Object.Json.shallowMap (WebSharper.Main.js?h=1127374076:316)
at decode (WebSharper.Main.js?h=1127374076:255)
at Object.Arrays.map (WebSharper.Main.js?h=1127374076:2364)
at Object.Json.shallowMap (WebSharper.Main.js?h=1127374076:316)
at decode (WebSharper.Main.js?h=1127374076:258)
at Object.Json.Activate (WebSharper.Main.js?h=1127374076:310)
at WebSharper.Main.js?h=1127374076:430
at XMLHttpRequest.k (WebSharper.Main.js?h=1127374076:482)
Jand42 commented 5 years ago

@granicz Thanks, this shows that if decimal is not used in the client-side, other than receiving it as an RPC result, this is currently not caught by the compiler but results in a run-time error.

Adding reference to WebSharper.MathJS package should resolve this.