Skip to content

docs: describe calling @ClientCallable methods from TypeScript (#6674) (CP: v25.3) - #6675

Merged
peholmst merged 1 commit into
v25.3from
cherry-pick-6674-to-v25.3-1794577818718
Nov 13, 2026
Merged

peholmst merged 1 commit into
v25.3from
cherry-pick-6674-to-v25.3-1794577818718

Conversation

@vaadin-bot

Copy link
Copy Markdown
Contributor

No description provided.

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>
@peholmst
peholmst merged commit dcc0813 into v25.3 Nov 13, 2026
9 of 10 checks passed
@peholmst
peholmst deleted the cherry-pick-6674-to-v25.3-1794577818718 branch November 13, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants