#Struggling to implement custom types with Next.js

3 messages · Page 1 of 1 (latest)

fast valve
#

How do I add custom types to my NextJS project? I have tried many different solutions via Google, i.e.

declare global {
    namespace NodeJS {
        export enum MyCustomEnum {
            ...
        }
    }
}
declare module "my-custom-module" {
    export enum MyCustomEnum { ... }
}

Neither of these approaches work and I'm stuck.

scenic ermine
#

@fast valve Generally with types you define them and export them and import them where necessary, rather than trying to declare things globally.

zenith inlet
#

yeah, those two approaches you showed are usually only used to add types for things you don't have control over (somebody else's package which lacks type definitions, or some global that only exists in a specific environment)