Getting this error message while building

default discord avatar
banks0
2 months ago

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);
}
    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!

    Star

    Connect with the Payload Community on Discord

    Discord

    online

    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.