Next.js Discord

Discord Forum

TypeScript Compilation Error with Next.js Custom Types

Answered
Whiskered Tern posted this in #help-forum
Open in Discord
Whiskered TernOP
I’m encountering a TypeScript compilation error in my Next.js project related to custom type definitions. The error message indicates a problem with the OmitWithTag utility type not satisfying a { [x: string]: never; } constraint. This seems to be causing issues with the compatibility of exported types from a module.

Here’s the error message I’m receiving:

Type error: Type 'OmitWithTag<typeof import("..."), "metadata" | "default" | "viewport" | "config" | ...>' does not satisfy the constraint '{ [x: string]: never; }'. Property 'Model' is incompatible with index signature.

The OmitWithTag type is intended to exclude certain properties from a type, but it appears that the resulting type does not meet the expected constraints. I’ve tried reviewing the type definitions and ensuring that the module exports are compatible with the defined types, but the error persists.

Could anyone provide insights on how to resolve this type error or suggest what changes might be needed to align the module’s types with the expected format?
Answered by joulev
You may only export certain things from page or layout files. “Modal” is not one of those things so you must not export “Modal”.
View full answer

2 Replies