Repository navigation
docs: describe calling @ClientCallable methods from TypeScript (#6674) (CP: v25.3) - #6675
Merged
Merged
Conversation
Fixes #989 ## What changed Adds a "Calling Server-Side Methods from TypeScript" section to the Remote Procedure Calls reference page (`articles/flow/component-internals/client-server-rpc.adoc`). A TypeScript class doesn't declare the `$server` property that Flow adds to the root element, so `this.$server.method()` doesn't compile, and users fall back to `(this as any).$server`. The new section shows how to: - describe the `@ClientCallable` methods in an interface whose methods return a `Promise` - declare `$server` with that type using `declare $server: GreetingServer;` in a Lit element - type an element received from outside the class as `HTMLElement & { $server: GreetingServer }` ## Notes for reviewers - `declare` rather than a plain field (or the `private $server: any;` suggested in the issue): Vaadin's generated `tsconfig.json` enables `strict`, so a typed field without `declare` fails with TS2564. This is also the pattern Flow Components uses, for example `declare $server: GridServer` in `vaadin-grid-flow-selection-column.ts`. - Verified against the Flow client source that every `@ClientCallable` method on `$server` returns a Promise (`bindServerEventHandlerNames` defaults `returnValue` to `true`). - Type-checked the example with TypeScript 6.0.3 and Lit 3.3.3 under Flow's default `tsconfig.json`: it compiles. Without `declare` it fails with TS2564, and with no declaration with TS2339. - Vale (`.vale-pr.ini`) reports nothing on the added lines. The site build wasn't run locally. - Labeled `target/v25.3`: the page is identical on `v25.3` and the behavior exists there. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.