Skip to content

Correctly integrating worker-configuration.d.ts into the TS configuration #9135

@kotkoroid

Description

@kotkoroid

Which Cloudflare product(s) does this pertain to?

Workers for Platforms

What versions & operating system are you using?

Wrangler 4.13.2, TypeScript 5.8.3, Node 22.14.0, macOS 15.3.2

Please provide a link to a minimal reproduction

No response

Describe the Bug

Hi,

I'm reaching out to clarify some aspects of integrating TypeScript into my project. Although I've been following the documentation, I found certain points to be unclear.

This page provides the following steps for proper integration:

  1. Update wrangler to version 4
  2. Generate types via wrangler types
  3. Add worker-configuration.d.ts into compilerOptions.types

I've successfully incorporated these steps into my codebase. However, I have a few questions to ensure I understand correctly:

  • Is the @cloudflare/workers-types package no longer required due to the --include-runtime flag being enabled by default in wrangler 4?
  • If so, can it be removed from tsconfig.json as well? The documentation mentions removing @cloudflare/workers-types imports in Worker code, but it's unclear if this applies to configurations as well.

Assuming the answer to both questions is yes, I noticed that in the TypeScript template, worker-configuration.d.ts is included in the include rather than compilerOptions.types. I'm guessing this might be because the template is still using wrangler 3, which would also explain @cloudflare/workers-types being still present in compilerOptions.types.

Could you provide clarification on this? The answer I am most looking for is whether I should include worker-configuration.d.ts in compilerOptions.types or include when using wrangler 4.

Please provide any relevant error logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions