stillmotion
stillmotion
Explore posts from servers
TTCTheo's Typesafe Cult
Created by stillmotion on 8/22/2023 in #questions
Why does vercel strip out authorization headers?
Ah, the issue was a www. redirect issue
2 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/10/2023 in #questions
Exporting prisma types from turborepo package
Ah such a subtle bug that took too long to figure out. I have two db packages that generate two different prisma clients. Because pnpm uses symlinked node_modules for workspaces, one db package was overwriting the other, so the one that got overwritten was exporting PrismaClient: any, which made it seem like all the types weren't being exported.
3 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
I've narrowed it down to commenting out this part of the .eslintrc.cjs:
overrides: [
{
extends: ["plugin:@typescript-eslint/recommended-requiring-type-checking"],
files: ["*.ts", "*.tsx"],
parserOptions: {
project: path.join(__dirname, "tsconfig.json"),
},
},
],
overrides: [
{
extends: ["plugin:@typescript-eslint/recommended-requiring-type-checking"],
files: ["*.ts", "*.tsx"],
parserOptions: {
project: path.join(__dirname, "tsconfig.json"),
},
},
],
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
yeah i'll check
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
Nothing out of the ordinary, so i'm assuming it's a config issue
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
And here's an example of my env.mjs
import { z } from "zod"
import { createEnv } from "@t3-oss/env-nextjs"

export const env = createEnv({
/**
* Specify your server-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars.
*/
server: {
R2_ACCOUNT_ID: z.string().min(1),
R2_ACCESS_KEY_ID: z.string().min(1),
R2_SECRET_ACCESS_KEY: z.string().min(1),
},

/**
* Specify your client-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars. To expose them to the client, prefix them with
* `NEXT_PUBLIC_`.
*/
client: {
},

/**
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
* middlewares) or client-side so we need to destruct manually.
*/
runtimeEnv: {
R2_ACCOUNT_ID: process.env.R2_ACCOUNT_ID,
R2_ACCESS_KEY_ID: process.env.R2_ACCESS_KEY_ID,
R2_SECRET_ACCESS_KEY: process.env.R2_SECRET_ACCESS_KEY,
},
})
import { z } from "zod"
import { createEnv } from "@t3-oss/env-nextjs"

export const env = createEnv({
/**
* Specify your server-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars.
*/
server: {
R2_ACCOUNT_ID: z.string().min(1),
R2_ACCESS_KEY_ID: z.string().min(1),
R2_SECRET_ACCESS_KEY: z.string().min(1),
},

/**
* Specify your client-side environment variables schema here. This way you can ensure the app
* isn't built with invalid env vars. To expose them to the client, prefix them with
* `NEXT_PUBLIC_`.
*/
client: {
},

/**
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
* middlewares) or client-side so we need to destruct manually.
*/
runtimeEnv: {
R2_ACCOUNT_ID: process.env.R2_ACCOUNT_ID,
R2_ACCESS_KEY_ID: process.env.R2_ACCESS_KEY_ID,
R2_SECRET_ACCESS_KEY: process.env.R2_SECRET_ACCESS_KEY,
},
})
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
import { env } from "~/env.mjs"

export const getR2Client = () => {
return new S3Client({
region: "auto",
endpoint: `https://${env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com`,
credentials: {
accessKeyId: env.R2_ACCESS_KEY_ID || "",
secretAccessKey: env.R2_SECRET_ACCESS_KEY || "",
},
})
}
import { env } from "~/env.mjs"

export const getR2Client = () => {
return new S3Client({
region: "auto",
endpoint: `https://${env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com`,
credentials: {
accessKeyId: env.R2_ACCESS_KEY_ID || "",
secretAccessKey: env.R2_SECRET_ACCESS_KEY || "",
},
})
}
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
Here's an example output:
./src/server/utils/r2.ts
10:26 Error: Invalid type "any" of template literal expression. @typescript-eslint/restrict-template-expressions
10:26 Error: Unsafe member access .R2_ACCOUNT_ID on an `any` value. @typescript-eslint/no-unsafe-member-access
12:7 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
12:20 Error: Unsafe member access .R2_ACCESS_KEY_ID on an `any` value. @typescript-eslint/no-unsafe-member-access
13:7 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
13:24 Error: Unsafe member access .R2_SECRET_ACCESS_KEY on an `any` value. @typescript-eslint/no-unsafe-member-access
./src/server/utils/r2.ts
10:26 Error: Invalid type "any" of template literal expression. @typescript-eslint/restrict-template-expressions
10:26 Error: Unsafe member access .R2_ACCOUNT_ID on an `any` value. @typescript-eslint/no-unsafe-member-access
12:7 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
12:20 Error: Unsafe member access .R2_ACCESS_KEY_ID on an `any` value. @typescript-eslint/no-unsafe-member-access
13:7 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
13:24 Error: Unsafe member access .R2_SECRET_ACCESS_KEY on an `any` value. @typescript-eslint/no-unsafe-member-access
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
I cleared my next cache and the error finally started to show inline in vscode. However, when I hover over the env import, it still shows the valid type. Running npm lint still errors.
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
The fact VSCode can see the type, but eslint can't see it is a sign eslint isn't configured correctly
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
just the one .cjs file
18 replies
TTCTheo's Typesafe Cult
Created by stillmotion on 5/8/2023 in #questions
Error: npm lint not seeing env type
Yeah it's exactly that. I've copy pasted it from the t3ca repo
18 replies