Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Getting this error message while building

default discord avatar
banks0last year

remote: 59.60 src/access/isAdmin.ts(2,22): error TS2307: Cannot find module '../payload-types' or its corresponding type declarations.


remote: 59.60 src/access/isLoggedIn.ts(2,22): error TS2307: Cannot find module '../payload-types' or its corresponding type declarations.


remote: 59.65 error Command failed with exit code 2.



isAdmin.ts



import { Access, FieldAccess } from "payload/types";
import { User } from "../payload-types";

export const isAdmin: Access<any, User> = ({ req: { user } }) => {
  // Return true or false based on if the user has an admin role
  return Boolean(user?.roles?.includes('admin'));
}

export const isAdminFieldLevel: FieldAccess<{ id: string }, unknown, User> = ({ req: { user } }) => {
  // Return true or false based on if the user has an admin role
  return Boolean(user?.roles?.includes('admin'));
}


isLoggedIn.ts


import { Access } from "payload/config";
import { User } from "../payload-types";

export const isLoggedIn: Access<any, User> = ({ req: { user } }) => {
  // Return true if user is logged in, false if not
  return Boolean(user);
}
    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.