error in compiler: Unable to get property 'toLowerCase' when building a simple 2 file 'project'


This may well be something I'm doing wrong, but the compiler should help guide me as to what it is I have wrong (or possibly this is a bug)

When I construct two files (project) as such.
where the contents of each file is

import utils = require("./utils/helpers.ts");

module utils {

    export function log(args) {

I then run tsc Version with this command

tsc .\Main.ts --module

I get the following error:
tsc.js(55958, 21) JavaScript runtime error: Unable to get property 'toLowerCase' of undefined or null reference
Any thoughts?
Closed Aug 27, 2013 at 9:24 PM by RyanCavanaugh
This has been fixed in the develop branch


staxmanade wrote Aug 27, 2013 at 5:38 AM

I worked it out (to get the compiler happy) but only got it to work with the VS tooling where it inferred the project. Still can't get the command-line to work with this sample.

file paths remained the same but the code in each file changed.

export module utils {
    export function log(args) {
import utilsMod = require("./utils/helpers");

var utils = utilsMod.utils;


staxmanade wrote Aug 27, 2013 at 5:46 AM

Ok, I looked at typescript.js at the line# in my file and realized that I am supposed to pass in a value to the --module parameter.

Might I suggest on the set: below that the argument is checked and possibly throw a helpful exception as to usages of the --module?
        opts.option('module', {
            usage: {
                locCode: TypeScript.DiagnosticCode.Specify_module_code_generation_0_or_1,
                args: ['commonjs', 'amd']
            type: TypeScript.DiagnosticCode.KIND,
            set: function (type) {
                type = type.toLowerCase();

                if (type === 'commonjs') {
                    _this.compilationSettings.moduleGenTarget = 1 /* Synchronous */;
                } else if (type === 'amd') {
                    _this.compilationSettings.moduleGenTarget = 2 /* Asynchronous */;
                } else {
                    _this.addDiagnostic(new TypeScript.Diagnostic(null, 0, 0, TypeScript.DiagnosticCode.Module_code_generation_0_not_supported, [type]));
        }, 'm');