Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sad-experts-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

fix: wrangler types should infer the types of the default worker entrypoint
4 changes: 2 additions & 2 deletions packages/wrangler/src/__tests__/type-generation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,9 @@ describe("generate types", () => {
D1_TESTING_SOMETHING: D1Database;
SECRET: SecretsStoreSecret;
HELLO_WORLD: HelloWorldBinding;
SERVICE_BINDING: Fetcher /* service_name */;
SERVICE_BINDING: Service<typeof import(\\"../b/index\\").default>;
OTHER_SERVICE_BINDING: Service /* entrypoint FakeEntrypoint from service_name_2 */;
OTHER_SERVICE_BINDING_ENTRYPOINT: Service<import(\\"../c/index\\").RealEntrypoint>;
OTHER_SERVICE_BINDING_ENTRYPOINT: Service<typeof import(\\"../c/index\\").RealEntrypoint>;
AE_DATASET_BINDING: AnalyticsEngineDataset;
NAMESPACE_BINDING: DispatchNamespace;
LOGFWDR_SCHEMA: any;
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/type-generation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,13 +464,13 @@ export async function generateEnvTypes(
: undefined;

const exportExists = serviceEntry?.exports?.some(
(e) => e === service.entrypoint
(e) => e === (service.entrypoint ?? "default")
);

let typeName: string;

if (importPath && exportExists) {
typeName = `Service<import("${importPath}").${service.entrypoint ?? "default"}>`;
typeName = `Service<typeof import("${importPath}").${service.entrypoint ?? "default"}>`;
} else if (service.entrypoint) {
typeName = `Service /* entrypoint ${service.entrypoint} from ${service.service} */`;
} else {
Expand Down
Loading