DenoDDeno
Powered by
90reasonz9
Denoβ€’17mo ago
90reasonz

How to get Deno to properly resolves global types when working in a SST project?

For context I am referencing this project as an example - https://github.com/sst/sst/tree/dev/examples/aws-deno

Steps to reproduce:
1. Ensure you have both node & deno installed on your machine (sst relies on node)
2. Open the project in VSCode (ensure the Deno extension installed & enabled)
3. Run deno install
4. Run sst install which will install providers and create
.sst
.sst
directory with types

Issue:
Deno is not recognizing the types referenced from
./.sst/platform/config.d.ts
./.sst/platform/config.d.ts
inside the sst.config.ts file. The type completion inside the sst config works properly when you turn the VSCode extension off. Any idea how to fix this to get proper type completion with the Deno VSCode extension turned on?

File contents of sst.config.ts
/// <reference path="./.sst/platform/config.d.ts" />

export default $config({
  app(input) {
    return {
      name: "aws-deno",
      removal: input?.stage === "production" ? "retain" : "remove",
      home: "aws",
    };
  },
  async run() {
    const vpc = new sst.aws.Vpc("MyVpc", { bastion: true });
    const redis = new sst.aws.Redis("MyRedis", { vpc });
    const cluster = new sst.aws.Cluster("MyCluster", { vpc });

    cluster.addService("MyService", {
      link: [redis],
      loadBalancer: {
        ports: [{ listen: "80/http", forward: "8000/http" }],
      },
      dev: {
        command: "deno task dev",
      },
    });
  },
});
/// <reference path="./.sst/platform/config.d.ts" />

export default $config({
  app(input) {
    return {
      name: "aws-deno",
      removal: input?.stage === "production" ? "retain" : "remove",
      home: "aws",
    };
  },
  async run() {
    const vpc = new sst.aws.Vpc("MyVpc", { bastion: true });
    const redis = new sst.aws.Redis("MyRedis", { vpc });
    const cluster = new sst.aws.Cluster("MyCluster", { vpc });

    cluster.addService("MyService", {
      link: [redis],
      loadBalancer: {
        ports: [{ listen: "80/http", forward: "8000/http" }],
      },
      dev: {
        command: "deno task dev",
      },
    });
  },
});


File contents of ./.sst/platform/config.d.ts
import "./src/global.d.ts"
import "../types.generated"
import { AppInput, App, Config } from "./src/config"
import * as _aws from "@pulumi/aws";


declare global {
  // @ts-expect-error
  export import aws = _aws
  interface Providers {
    providers?: {
      "aws"?:  (_aws.ProviderArgs & { version?: string }) | boolean | string;
    }
  }
  export const $config: (
    input: Omit<Config, "app"> & {
      app(input: AppInput): Omit<App, "providers"> & Providers;
    },
  ) => Config;
}
import "./src/global.d.ts"
import "../types.generated"
import { AppInput, App, Config } from "./src/config"
import * as _aws from "@pulumi/aws";


declare global {
  // @ts-expect-error
  export import aws = _aws
  interface Providers {
    providers?: {
      "aws"?:  (_aws.ProviderArgs & { version?: string }) | boolean | string;
    }
  }
  export const $config: (
    input: Omit<Config, "app"> & {
      app(input: AppInput): Omit<App, "providers"> & Providers;
    },
  ) => Config;
}
GitHub
sst/examples/aws-deno at dev Β· sst/sst
Build full-stack apps on your own infrastructure. Contribute to sst/sst development by creating an account on GitHub.
sst/examples/aws-deno at dev Β· sst/sst
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How do you get a Deno Jupyter notebook to recognize Deno and other types in vscode?
cdoremusCcdoremus / help
3y ago
Deno Types
mostprodevMmostprodev / help
3y ago
How to publish global types with JSR?
rezi99Rrezi99 / help
2y ago