sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.09k stars 126 forks source link

`sst-env.d.ts` Generation Missing Export in Monorepo Workspace #556

Open isaac-scarrott opened 2 weeks ago

isaac-scarrott commented 2 weeks ago

Hey,

I'm seeing an issue with sst-env.d.ts in my monorepo. I have two sst-env.d.ts files being generated, one in the root and one in my cloudflare worker folder/workspace.

The root sst-env.d.ts seems to be correct and look something like the following:

/* tslint:disable */
/* eslint-disable */
import "sst"
declare module "sst" {
  export interface Resource {
    Api: {
      type: "sst.cloudflare.Worker"
      url: string
    }
  }
}
export {}

However, the sst-env.d.ts generated in my app/workspace folder seems to be causing an issue as it does not have export {} at the end and is causing the error 'Resource' only refers to a type, but is being used as a value here when attempting to reference the resource

Also note that this is a project deployed to cloudflare.

isaac-scarrott commented 2 weeks ago

Please let me know if you wish me to create a minimal repository to reproduce this issue

jayair commented 6 days ago

We made some changes to this recently, can you update your CLI?

Also have a look at how our monorepo example has it: https://github.com/sst/ion/blob/dev/examples/aws-monorepo/packages/functions/sst-env.d.ts & https://github.com/sst/ion/blob/dev/examples/aws-monorepo/sst-env.d.ts

Lmk if that helps.

isaac-scarrott commented 5 days ago

Hey @jayair, upgrading didn't help unfortunately and I'm following the examples correct. I believe it's this commit and specifically this line that has caused this to happen.

I believe the fix would be to add export {}, to the line after this one would fix this issue. Similar to how there is this line here for the root sst-env.d.ts that enables all of my non cloudflare resources to pass the type checks.

I would test this locally and raise a PR however, I can't work out how to run the CLI locally so if I could get some guidance on how to run it locally or someone else could fix it that would be great