Skip to content

typescript error with react #2825

@hyusetiawan

Description

@hyusetiawan

Environment

node

  • Rivet Cloud
    • Game ID: [please provide]
  • Rivet self-hosted local
    • Version/commit: 0.9.8
  • Rivet self-hosted cluster
    • Version/commit: [please provide]

Description

following the given example, gives me a typescript error:

// in registry.ts
import {actor, setup} from '@rivetkit/actor'

export const counter = actor({
  onAuth: () => {}, // Skip authentication (can be configured later)
  state: {count: 0},
  actions: {
    increment: (c, amount: number = 1) => {
      c.state.count += amount
      c.broadcast('countChanged', c.state.count)
      return c.state.count
    },
    getCount: c => c.state.count,
  },
})

export const registry = setup({
  use: {counter},
})

// in hook.ts
import {createClient, createRivetKit} from '@rivetkit/react'
import type {registry} from './registry'

export const client = createClient<typeof registry>('http://localhost:8080')
export const {useActor} = createRivetKit(client)

the TS error:

Type 'Registry<{ counter: ActorDefinition<{ count: number; }, unknown, unknown, unknown, unknown, void, AnyDatabaseProvider, { increment: (c: ActionContext<{ count: number; }, unknown, unknown, unknown, unknown, void, AnyDatabaseProvider>, amount?: number) => number; getCount: (c: ActionContext<...>) => number; }>; }>' does not satisfy the constraint 'Registry<any>'.
  Property '#private' in type 'Registry' refers to a different member that cannot be accessed from within type 'Registry'.ts(2344)
(alias) const registry: Registry<{
    counter: ActorDefinition<{
        count: number;
    }, unknown, unknown, unknown, unknown, void, AnyDatabaseProvider, {
        increment: (c: ActionContext<{
            count: number;
        }, unknown, unknown, unknown, unknown, void, AnyDatabaseProvider>, amount?: number) => number;
        getCount: (c: ActionContext<...>) => number;
    }>;
}>
import registry

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions