sst: `sst-env.d.ts` broken in monorepos

Description

Moving some files (?) out of root breaks typing.

Steps to reproduce

git clone git@github.com:sst/ion.git
cd ion/examples/cloudflare-trpc
mkdir trpc
mv *.ts ./trpc
cp tsconfig.json trpc/tsconfig.json

lastly, update paths in sst.config.ts:

diff --git a/examples/cloudflare-trpc/sst.config.ts b/examples/cloudflare-trpc/sst.config.ts

     const trpc = new sst.cloudflare.Worker("Trpc", {
       url: true,
-      handler: "index.ts",
+      handler: "trpc/index.ts",
     });

     const client = new sst.cloudflare.Worker("Client", {
       url: true,
       link: [trpc],
-      handler: "client.ts",
+      handler: "trpc/client.ts",
     });

Result

Both trpc/sst-env.d.ts and sst-env.d.ts define the same resources, leading to incompatible types

Subsequent property declarations must have the same type.
Property '"Trpc"' must be of type '{ type: "sst.cloudflare.Worker"; url: string; }',
but here has type 'Service<undefined>'.ts(2717)
> sst-env.d.ts

import "sst"
declare module "sst" {
  export interface Resource {
    "Client": {
      "type": "sst.cloudflare.Worker"
      "url": string
    }
    "Trpc": {
      "type": "sst.cloudflare.Worker"
      "url": string
    }
  }
}
export {}
> trpc/sst-env.d.ts

/// <reference path="../sst-env.d.ts" />
// cloudflare 
declare module "sst" {
  export interface Resource {
    "Trpc": import("@cloudflare/workers-types").Service
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

yeah i might actually loosen this and just do all package.json even if it doesn’t contain sst - some people just install at root and rely on hoisting

but glad to see it works

i believe this is fixed in 3.1.0

this hasn’t been released yet, working on getting it merged today