Skip to content

Actions context callAction exists and can call another Actions #13394

Open
@reidark

Description

@reidark

Astro Info

Astro                    v5.4.2
Node                     v22.13.1
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  none
Integrations             @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I'm building my a new project with Astro Actions to work very similar to a tRPC project that I have.

After some tests, I found out that the context argument from the handler function doesn't have the callAction method (by types). It's fine (kind of), but it have hit like a missing feature and doesn't convinced me at the time. So, after some research I found this issue opened last month with the same kind of problem. The OP there said that he couldn't call the callAction method, as the types intended.

error ts(2339): Property 'callAction' does not exist on type 'ActionAPIContext'.

But, I just tested it, and, for some reason, worked. I don't know why, but I tested with some examples and all seems to work fine.

For context, in the Minimal Reproducible Example I'm showing two actions being called inside a third action and the results are rendered in index page.

I'm not too deep in the codebase, but I think the method exists here but it's omited here.

So, the question is: Is this intended to work but for some reason the types were just left there? Or, if this is a bug, it's safe to use? This resolves a lot of things for me and it's a great feature to have.

What's the expected result?

Following the type system, the context inside action handlers doesn't have a callAction method. But, after some tests, it seems to have the method.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-h9uqr783?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)feat: actionsRelated to Astro actions (scope)requires refactorBug, may take longer as fixing either requires refactors, breaking changes, or considering tradeoffs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions