Skip to content

[BUG] TypeScript Binding Generation doesn't work #238

@wesbos

Description

@wesbos

Describe the bug

I'm using npx wrangler types --experimental-include-runtime to generate my binding types, which creates a worker-configuration.d.ts file in the root of my project that looks like this:

// Generated by Wrangler by running `wrangler types --experimental-include-runtime`

interface Env {
	OG: KVNamespace;
	DB: D1Database;
	ASSETS: Fetcher;
}

Now the types for (await getCloudflareContext()).env. look like this

Screenshot 2025-01-08 at 4 48 48 PM

Because this package ships then like this:

declare global {
    interface CloudflareEnv {
        NEXT_CACHE_WORKERS_KV?: KVNamespace;
        ASSETS?: Fetcher;
    }
}

If I rename the generated types to CloudflareEnv I see everything:

Screenshot 2025-01-08 at 4 50 04 PM

So either this package or the wrangler types command need to agree on the Env / CloudflareEnv naming?

Steps to reproduce

see above

Expected behavior

see above

@opennextjs/cloudflare version

0.3.4

Wrangler version

3.99.0

next info output

15.1.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions