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

TypeScript and RequireJs work well together. Writing small modular code with Single Responsibilities (SOLID principles) is a good practice in any language and JavaScript is not an exception.


AMD-Dependency Path

Use amd-dependency path to include files you don’t need to use in code, but need to be loaded in order to run

/// <amd-dependency path=”knockout-es5” />


Use import (translates to define([‘jquery’]) for adding in dependencies. Casing matters and must match the casing of the file name. We name all of our TypeScript files starting with lower case.

A file that is included in the html source or at startup can be used for shortcuts to paths. Without this you’d have to do import $ = require(“Common/lib/jquery”) everywhere.

   paths: { “jquery”: “Common/lib/jquery” …}
import $ = require(“jquery”);
import myDataAccess = require(“dataAccess/myDataAccess”);
“use strict;” // must go after import - see
class ILikeClassesInTypeScript {


export = ILikeClassesInTypeScript;

This article explains in more detail.

You can optimize the code (minifiy and combine) using a grunt task, since you don’t want the browser to have to retrieve the many modular files you’ll be creating. We’ve been using Grunt, but there are many Gulp plugins as well.

Posted on Friday, February 6, 2015 10:47 PM TypeScript , RequireJS , Grunt , Gulp | Back to top

Comments on this post: TypeScript and RequireJs

# re: TypeScript and RequireJs
Requesting Gravatar...
There's an example of a visual studio solution that uses typescript and requirejs and also uses an r.js-created bundle of the new aurelia libraries here:

info on using the r.js bundler is here:
Left by Mike Graham on Feb 14, 2015 8:51 AM

Your comment:
 (will show your gravatar)

Copyright © Aligned | Powered by: