Skip to content
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

Add a warning if an RPC is returning type without full client support #1058

Closed
Jand42 opened this issue Jul 18, 2019 · 0 comments
Closed

Add a warning if an RPC is returning type without full client support #1058

Jand42 opened this issue Jul 18, 2019 · 0 comments

Comments

@Jand42
Copy link
Member

Jand42 commented Jul 18, 2019

If a TradeResponse value is returned from an RPC where it is:

type Trade = {qty: decimal ; cpty: string }
type TradeResponse = 
| ServerResp of Trade array
| ServerError of string

if decimals are not used in the client, WS will miss the client-side dependency on it currently. When translating an RPC call, a type dependency is added for the result which has dependencies in turn on field types, so the dependency graph should tie the use of TradeResponse to needing decimals on the client side, but only if WebSharper has metadata for the types involved. If an F# record or union does not have the [<JavaScript>] attribute, WS still provides some basic translation support, translating them to plain objects. So currently there is no compile-time error or warning, but project can fail because of the math.js dependency is not auto-discovered.

A general and non-breaking solution, that would help uncover similar issues: add a warning at each call when an RPC is returning a type without full WS metadata, suggesting to use JS attribute or proxy for them.

See https://forums.websharper.com/topic/87068

@Jand42 Jand42 changed the title Type dependencies for remoting result Add a warning if an RPC is returning type without full client support Jul 19, 2019
@Jand42 Jand42 closed this as completed Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant