Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.



Programming and Learning from SD

I have a TypeScript class with PascalCasing, but the file name was camelCasing.ts  (to match our other existing js files) and my TypeScript wouldn’t complied in our Gated Check-in build. It turns out that this is converted to a RequireJs define call, which looks at the filename, not the class name. That took awhile and help from team members to figure out. I hope you can avoid losing time like I did.

Here’s a quick example:

// my Typescript model, file name is webCam.ts
class WebCam {
    id: string;
    title: string;
    ipAddress: string;
    webCamTypeId: string;
    constructor(id: string, title:string, ipAddress:string, webCamTypeId:string) {
        this.id = id;
        this.title = title;
        this.ipAddress = ipAddress;
        this.webCamTypeId = webCamTypeId;
    }
}

export = WebCam;
// TypeScript view model requiring the webCam module (not the camelCasing)
import WebCam = require('./webCam');
class WebCamViewModel {
    webCam: WebCam;
    constructor() {
        this.webCam = new WebCam("1", "test", "127.0.0.1", "1");
    }
}

export = WebCamViewModel;
// output of the generated JS
define(["require", "exports", './webCam'], function(require, exports, WebCam) {
    var WebCamViewModel = (function () {
        function WebCamViewModel() {
            this.webCam = new WebCam();
        }
        return WebCamViewModel;
    })();

    
    return WebCamViewModel;
});
//# sourceMappingURL=webCamsViewModel.js.map
Posted on Tuesday, October 28, 2014 8:26 PM TypeScript , RequireJS | Back to top


Comments on this post: TypeScript Import casing matters

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Aligned | Powered by: GeeksWithBlogs.net