Skip to content

docs: describe calling @ClientCallable methods from TypeScript - #6674

Merged
peholmst merged 1 commit into
mainfrom
claude/vaadin-docs-989-c53652
Nov 13, 2026
Merged

peholmst merged 1 commit into
mainfrom
claude/vaadin-docs-989-c53652

Conversation

@peholmst

Copy link
Copy Markdown
Member

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

A TypeScript class doesn't declare the $server property that Flow adds
to the root element, so calls to @ClientCallable methods don't compile
without a cast to any. Show how to type $server with an interface and a
declare field, and how to type an element passed from outside the class.

Fixes #989

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@peholmst peholmst added the target/v25.3 Automatically cherry-pick to the v25.3 branch label Nov 13, 2026

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Nothing to flag — the changes look good.

@github-actions

Copy link
Copy Markdown
Contributor

Preview Deployment

This PR has been deployed for preview.

URL: https://docs-preview-pr-6674.fly.dev

Changed pages

Added content is highlighted in green; removed content is marked in red on each page.

Built from 27cdd1e

@peholmst
peholmst merged commit 50132cc into main Nov 13, 2026
13 checks passed
@peholmst
peholmst deleted the claude/vaadin-docs-989-c53652 branch November 13, 2026 13:44
peholmst added a commit that referenced this pull request Nov 13, 2026
… (CP: v25.3) (#6675)

Co-authored-by: Petter Holmström <petter@vaadin.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked-v25.3 target/v25.3 Automatically cherry-pick to the v25.3 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document @ClientCallable invocations from TS

3 participants