Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8768981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:12:41+00:00 2026-06-13T17:12:41+00:00

Why would the TypeScript compiler issue error The name m does not exist in

  • 0

Why would the TypeScript compiler issue error “The name m does not exist in the current scope” in Logger.ts even though it is able to resolve Model.LogMessage defined LogMessage.ts

These are the associated files:

Logger.ts:

    ///<reference path="Utils.ts"/>
    /// <reference path="../Models/LogMessage.ts"/>
    /// <reference path="JqGridUtilities.ts"/>



    module Utilities {

        declare var $;
        import m = Model;
        //import jqu = Utilities;

        export class Logger {        

                static logs:  m.LogMessage[];  // how to do typed array????

                logs1: m.LogMessage[];

                static logsGridClass = "jqgdash_logs";
                static gridName = "jqgdash";
                static logsGridHeader = "Info Center";            

  static displayDataOnConsole(gridClass : string, gridHeader : string, theData) {

                if (theData != null && theData.length > 0) {
                    var grid = $("#" + gridName);

                    if (gridClass === logsGridClass) {
                        if (!grid.hasClass(logsGridClass)) {
                            GridUtils.reconfigureGrid(gridName, gridHeader, theData);
                            grid.addClass(logsGridClass);
                        } else {
                            GridUtils.addDataToGrid(gridName, gridHeader, theData);
                        }   
                    } else {
                        if (grid.hasClass(logsGridClass)) {
                            grid.removeClass(logsGridClass);
                    }

                    GridUtils.reconfigureGrid(this.gridName, gridHeader, theData);
                }
            }
        }


          static  createErrorLogs(messages : string) : m.LogMessage[] {
                    if (messages == null) return [];
                    $.each(messages, function (i, msg) {
                        logs.push(this.createLogJson("error", msg));
                    });

                    return logs;
                }

           static logMessageToConsole (severity : string, message : string) {
                    this.logs.push(this.createLogJson(severity, message));
                }      
            }      
    }

LogMessage.ts:

module Model { 
       export class LogMessage {

        message: string;
        timeStamp: Date; 
        severity: string;

        constructor (severity : string, message: string, date: Date) {
            this.message = message;
            this.timeStamp = date;
            this.severity = severity;
        }
     }
}

and Utils.ts:

module Utils { 

    declare var tut;

   export var liveString = "http://" + window.location.host + '/trackutransit';

    export function executeAjaxPostJsonCall(url : string, success : any ) { 
        return  $.ajax(url,
        {
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            error: tut.Logger.displayAjaxError,
            success : success  });
         }

   export function getResourcePath(relativePath: string): string {
            return liveString + relativePath;
        }

    export function isMobile(): bool {
            var index = navigator.appVersion.indexOf("Mobile");
            return (index > -1);
        }
}

JQGridUtilities.ts is defined in the same folder as Logger.ts as follows:

///<reference path="Utils.ts"/>
module Utilities{

    declare var jqGrid;


    declare var $;
    //import t = TrackuTransit;

    export class GridUtils {

        static instance = new GridUtils();

        constructor() { }

      static  isUserFriendlyField(key : string) : bool {    
        return true;
    }

    // Extracts the fields from this Json object
   static extractColumnsFromJsonObject(obj) : any[]{
        var columns = new Array();
        if (obj) {
            for (var key in obj) {
                if (isUserFriendlyField(key)) {
                    columns.push(key);
                }
            }
        }

        return columns;
    }

   static  addDataToGrid(gridId, gridHeader, data) {
        if (data != null) {
            var grid = $("#" + gridId);
            for (var i = 0; i < data.length; i++) {
                grid.jqGrid('addRowData', i, data[i]);
            }
        }
    }

    static createColumnModels(columns)  : any[]{

        var model = [];

        $.each(columns, function (i, column) {
            if (this.isUserFriendlyField(column)) {
                if (column === "icon" || column === "image") {
                    model.splice(0, 0, { name: column, label: ' ', width: 16, formatter: function (cellvalue, options, rowObjects) {
                        return "<img src='" + cellvalue + "' width='16px' height='16px'/>";
                    }
                    });
                }
                else if (column === "Severity") {
                    model.splice(0, 0, {
                        name: column,
                        label: ' ',
                        width: 20,
                        formatter: function (cellvalue, options, rowObjects) {
                            var imagePath = Utils.liveString + '/Content/images/' + cellvalue + '.png';
                            return "<img src='" + imagePath + "' width='16px' height='16px'/>";
                        }
                    });
                }
                else {
                    if (column === "display_name") {
                        model.splice(0, 0, { name: column, label: "name" });
                    } else {
                        model.push({ name: column, label: column, width: 70 });
                    }
                }
            }
        });

        return model;
    }

   static reconfigureGrid(gridName, gridHeader, theData) {
        if (!gridName)
            throw ("grid name must be specified");

        if (gridHeader, theData != null && gridHeader, theData.length > 0) {

            var columns = extractColumnsFromJsonObject(theData[0]);
            var colsModel = createColumnModels(columns);

            // todo: report unable to chain jQuery methods as bug for jqGrid
            $("#" + gridName).jqGrid('GridUnload');
            $("#" + gridName).jqGrid({
                datatype: "local",
                data: theData,
                autowidth: true,
                colModel: colsModel,
                pager: '#pager',
                rowNum: 10,
                rowList: [5, 10, 20, 50],
                height: 120,   // constant height allows grid navigator to show, if parent div is constant height
                width: '100%',
                viewrecords: true,
                caption: gridHeader
            });
        }
    }


    }

}

If I remove reference to JqGridUtilities.ts in Logger.ts, the error disappears but now GridUtils can no longer be resolved. If I define GridUtils using a different module name, say, jqGridUtilities instead of Utilities, I no longer get this error. Why is this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:12:42+00:00Added an answer on June 13, 2026 at 5:12 pm

    This is what I have based on your examples…

    It looks like you are going for a bundling strategy… i.e. you are asking TypeScript to leave how the JavaScript gets loaded to you. You will either add all the scripts to the page or you’ll bundle them into a single file and minify it.

    When you do this, you can pretty much ignore the import keyword and just use reference comments to describe the files that you will make available at runtime.

    With this in mind, here is your Logger.ts file

    The changes are mainly the absence of the import statements, but I have also shown how you instantiate a typed array (you just follow the declaration with = [].

    /// <reference path="Utils.ts"/>
    /// <reference path="./Models/LogMessage.ts"/>
    /// <reference path="JqGridUtilities.ts"/>
    
    module Utilities {
        declare var $;
    
        export class Logger {
    
            static logs: Model.LogMessage[] = [];  // how to do typed array? - Like this
    
            logs1: Model.LogMessage[] = [];
    
            static logsGridClass = "jqgdash_logs";
            static gridName = "jqgdash";
            static logsGridHeader = "Info Center";
    
            static displayDataOnConsole(gridClass: string, gridHeader: string, theData) {
    
                if (theData != null && theData.length > 0) {
                    var grid = $("#" + gridName);
    
                    if (gridClass === logsGridClass) {
                        if (!grid.hasClass(logsGridClass)) {
                            GridUtils.reconfigureGrid(gridName, gridHeader, theData);
                            grid.addClass(logsGridClass);
                        } else {
                            GridUtils.addDataToGrid(gridName, gridHeader, theData);
                        }
                    } else {
                        if (grid.hasClass(logsGridClass)) {
                            grid.removeClass(logsGridClass);
                        }
    
                        GridUtils.reconfigureGrid(this.gridName, gridHeader, theData);
                    }
                }
            }
    
    
            static createErrorLogs(messages: string): m.LogMessage[] {
                if (messages == null) return [];
                $.each(messages, function (i, msg) {
                    logs.push(this.createLogJson("error", msg));
                });
    
                return logs;
            }
    
            static logMessageToConsole(severity: string, message: string) {
                this.logs.push(this.createLogJson(severity, message));
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would a C++ CLI compiler be able to compile some large sets of C++
Would anyone know why the bmlabel is not updated? and the log score shows
Looks like TypeScript has a nice module system, however does this replace the need
I am building a Backbone app in TypeScript and I would like to put
I'm new to TypeScript and JavaScript, although not completely new to programming. I wondered
Would someone kindly tell me why the complier flags an error when I attempt
Would it prevent, for example, session hijacking? If not, what can I do to
Would somebody be so pleasant to explain why does the next thing happen? Here
Would it not make sense to support a set of languages (Java, Python, Ruby,
Would the following SQL remove also the index - or does it have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.