Search code examples
node.jsloopback4

I am getting the error in loopback 4 framework. How to solve this error?


(method) MyUserService.convertToUserProfile(user: User): UserProfile Convert the user returned by verifyCredentials() to a common user profile that describes a user in your application

Property 'convertToUserProfile' in type 'MyUserService' is not assignable to the same property in base type 'UserService<User, Credentials>'.
  Type '(user: import("d:/lb4/lllog/test/src/models/user.model").User) => import("d:/lb4/lllog/test/node_modules/@loopback/authentication/dist/types").UserProfile' is not assignable to type '(user: import("d:/lb4/lllog/test/src/models/user.model").User) => import("d:/lb4/lllog/test/node_modules/@loopback/security/dist/types").UserProfile'.
    Property '[securityId]' is missing in type 'import("d:/lb4/lllog/test/node_modules/@loopback/authentication/dist/types").UserProfile' but required in type 'import("d:/lb4/lllog/test/node_modules/@loopback/security/dist/types").UserProfile'.ts(2416)
types.d.ts(12, 5): '[securityId]' is declared here.
Peek Problem
No quick fixes available

Solution

  • Can you try some thing like this ?

    convertToUserProfile(user: User): UserProfile {
        return {
          id: user.id,
          name: '<' + user.email + '>' + user.name,
          [securityId]: user.id,
        };
      }