Skip to content

[RSC] Type error when defining route's ServerComponent as arrow function #14676

@r52j

Description

@r52j

Reproduction

Have a look at the type error in https://stackblitz.com/edit/github-q8quohkd?file=app%2Froutes%2Fhome.tsx

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  Languages:
    Bash: 1.0 - /bin/bash
    Python: 0.2.0
    Python3: 0.2.0 - /usr/local/bin/python3

Used Package Manager

npm

Expected Behavior

Defining the server component as

export const ServerComponent = ({}: Route.ComponentProps) => …

yields correct types and no type error

Actual Behavior

We get the type error

TS7022: 'ServerComponent' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

Workaround: Define function as

export const ServerComponent: (props: Route.ComponentProps) => JSX.Element = ({}) => …

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions