Skip to content

c.env.* typed as unknown after void prepare #53

Description

@totallynotdavid

dependencies: void: 0.9.0 | ts: 6.0.3, also 5.9.3
repo: https://github.com/totallynotdavid/void-env-repro


Even after void prepare, any env var accessed via c.env in a handler is typed as unknown despite being declared in env.ts.

TS2345: Argument of type 'unknown' is not assignable to parameter of type 'string'.

The cause seems to be the generated .void/env.d.ts:

type _VoidEnvShape = _VoidEnvSchema extends { default: infer D } ? D : ...;

declare module "void/handler" {
  interface CloudBindings extends _VoidEnvShape {}
}

Note: this surfaces only when typeAware and typeCheck are enabled in the vite-plus lint options.

The workaround i've used:

import type { CloudBindings } from "void/handler";

declare module "void/handler" {
  interface CloudBindings {
    API_SECRET: string;
  }
}

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions