90reasonz
90reasonz
DDeno
Created by 90reasonz on 11/6/2024 in #help
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 directory with types Issue: Deno is not recognizing the types referenced from ./.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;
}
1 replies