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/tall-forks-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-cloudflare': patch
---

fix: avoid type collision with user defined `App.Platform` `env` property
3 changes: 2 additions & 1 deletion packages/adapter-cloudflare/ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
declare global {
namespace App {
export interface Platform {
env: unknown;
// we should not type `env` here because it will override any type set by
// the user in `src/app.d.ts`
ctx: ExecutionContext;
/** @deprecated Use `ctx` instead */
context: ExecutionContext;
Expand Down
5 changes: 2 additions & 3 deletions packages/adapter-cloudflare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ export default function (options = {}) {
// If we would await it here, it would hang indefinitely because the platform proxy only resolves once a request happens
const get_emulated = async () => {
const proxy = await getPlatformProxy(options.platformProxy);
const platform = /** @type {App.Platform} */ ({
const platform = {
env: proxy.env,
ctx: proxy.ctx,
context: proxy.ctx, // deprecated in favor of ctx
caches: proxy.caches,
cf: proxy.cf
});
};
/** @type {Record<string, any>} */
const env = {};
const prerender_platform = /** @type {App.Platform} */ (/** @type {unknown} */ ({ env }));
Expand All @@ -203,7 +203,6 @@ export default function (options = {}) {
return { platform, prerender_platform };
};

/** @type {{ platform: App.Platform, prerender_platform: App.Platform }} */
let emulated;

return {
Expand Down
Loading