Next.js Discord

Discord Forum

Global Types

Answered
Havana posted this in #help-forum
Open in Discord
Avatar
HavanaOP
I'm creating a global type named ContactResponse in the file src/types/global.d.ts like this:

declare global {
    type ContactResponse = {
        status: boolean;
        message: {
            title: string;
            description: string;
        };
    };
}


But, it's not working in this project, while it does in other projects. I'm not sure why, and it seems strange.
Answered by Havana
it looks like the .d.ts putting thing in the global scope by default so I removed the global declare and it works!
type ContactResponse = {
    status: boolean;
    message: {
        title: string;
        description: string;
    };
};

But it's also weird it's working on other projects.
View full answer

1 Reply

Avatar
HavanaOP
it looks like the .d.ts putting thing in the global scope by default so I removed the global declare and it works!
type ContactResponse = {
    status: boolean;
    message: {
        title: string;
        description: string;
    };
};

But it's also weird it's working on other projects.
Answer