Need Help with Enum

General Discussion
  • Hello People,
    I have an application where I am exporting enum like this
    path (D:\mainfolder\myapp\shared\constants\errors.ts)

    export const RESPONSE_ERROR_MESSAGES: { [key: string]: string } = {   
      'IncorrectUsernameOrPassword': 'IncorrectUsernameOrPassword',
    };
    

    and importing here
    path (D:\mainfolder\myapp\server\core\shared\constants\errors.ts)

    import { errorMessagesNames } from '../../../../shared/constants/errors';
    
    export interface IErrorMessage {
      code: number;
      name: string;
      message: string;
    }
    
    export const errorMessages = Object.freeze({
      LOGIN_UNAUTHORIZED: {
        code: 2,
        message: 'The username and password you entered did not match our records. Please double-check and try again.',
        name: errorMessagesNames.IncorrectUsernameOrPassword
      }
    });
    

    in other files where I am using something like this

    TestServerHelper.userError(error, {
           app: {
             code: 2,
             description: 'The username and password you entered did not match our records. Please double-check and try again.',
             name: 'IncorrectUsernameOrPassword',
             user: { authenticated: false, _id: null }
           }
         });
    

    No problem in above code and files

    Problem is I have one other file, where I have code like this
    path (D:\mainfolder\myapp\client\app\shared\constants.ts)

    export const RESPONSE_ERROR_MESSAGES: { [key: string]: string } = {
      'IncorrectUsernameOrPassword': 'error_user_not_found',
    };
    

    I am not understanding how to use enum in this above file.

  • Hey there! This is actually not a forum for Node.js, but for NodeBB specifically, sorry!


Suggested Topics