Skip to content

TypeScript declarations don't match runtime exports for Turnstile #46

Open

Description

@AshmitSherigar

Describe the bug

The package exports a named Turnstile component at runtime, but the published TypeScript declarations do not declare that export.

Runtime (dist/index.js)

exports.useTurnstile = exports.Turnstile = void 0;

This allows:

import { Turnstile } from "react-turnstile";

to work at runtime.

Type declarations (dist/index.d.ts)

export declare function TurnstileTurnstile(...): JSX.Element;
export default Turnstile;
export declare function useTurnstile(): TurnstileObject;

There is no declaration for the named export Turnstile, so TypeScript reports:

Module '"react-turnstile"' has no exported member 'Turnstile'. Did you mean 'useTurnstile'?

Expected behavior

The TypeScript declarations should match the runtime exports so the named import works without TypeScript errors.

Additional context

I'm happy to work on a fix if this is considered a bug.

Activity

  1. Le0Developer commented on Jul 31, 2026

    @Le0Developer
    Owner

    I cannot find any version that ever exported "TurnstileTurnstile" in the types.

    Where did you find this?

  2. AshmitSherigar commented on Jul 31, 2026

    @AshmitSherigar
    Author

    sorry i checked it again seemed like i missread the index.d.ts

    Image

    i got this error when i was trying to implement this in a contact page

  3. Le0Developer commented on Jul 31, 2026

    @Le0Developer
    Owner
    1. what version
    2. how are you importing
  4. AshmitSherigar commented on Jul 31, 2026

    @AshmitSherigar
    Author

    react-turnstile@1.1.5
    import { Turnstile } from 'react-turnstile';

  5. AshmitSherigar commented on Jul 31, 2026

    @AshmitSherigar
    Author

    seems like vscode asks me to use import Turnstile from 'react-turnstile';
    but there is no exported component like that
    Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object

  6. Le0Developer commented on Jul 31, 2026

    @Le0Developer
    Owner

    According to #45 that is because of rolldown being stupid and the reason why the named export exists now

  7. AshmitSherigar commented on Jul 31, 2026

    @AshmitSherigar
    Author

    According to #45 that is because of rolldown being stupid and the reason why the named export exists now

    Thanks for the explanation. I wasnt aware of #45. That explains why the named export was added and why I ran into the runtime issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions