Contents tagged with jQuery

  • Creating a TypeScript Workflow with Gulp

    TypeScript provides a lot of great functionality that lets you leverage many of the features available in ES6 today but how do you get started using it in your favorite editor? If you’re using Visual Studio or WebStorm then TypeScript support can be used directly and everything happens magically without much work on your part. But, if you’re using Sublime Text, Brackets, Atom, or another editor you’ll have to find a plugin to compile .ts files to JavaScript or create your own custom workflow.

    While several plugins exist to compile TypeScript and even provide code help as you’re writing TypeScript code in different editors, I generally prefer to use my own custom workflow. There are multiple benefits associated with going with this approach including the ability to standardize and share tasks across team members as well as being able to tie the workflow into a custom build process used in continuous integration scenarios. In this post I’ll walk through the process of creating a custom TypeScript workflow using Gulp (a JavaScript task manager). It’s a workflow setup that my friend Andrew Connell and I created when we recently converted an application to TypeScript. Throughout the post you’ll learn how to setup a file named gulpfile.js to compile TypeScript to JavaScript and also see how you can “lint” your TypeScript code to make sure it’s as clean and tidy as possible.

    Getting Started Creating a Custom TypeScript Workflow

    I talked about using Gulp to automate the process of transpiling ES6 to ES5 in a previous post. The general process shown there is going to be used here as well although I’ll be providing additional details related to TypeScript. If you’re new to Gulp, it’s a JavaScript task manager that can be used to compile .ts files to .js files, lint your TypeScript, minify and concatenate scripts, and much more. You can find additional details at

    Here’s a step-by-step walk-through that shows how to get started creating a TypeScript workflow with Gulp. Although there are several steps to perform, it’s a one-time setup that can be re-used across projects. If you’d prefer to use a starter project rather than walking through the steps that are provided in this post then see the project at or download the project associated with the exact steps shown in this post here.

    Creating the Application Folders and Files

    1. Create a new folder where your project code will live. You can name it anything you’d like but I’ll call it typescriptDemo in this post.
    2. Create the following folders inside of typescriptDemo:
      • src
      • src/app
      • src/js

    3. Open a command-prompt in the root of the typescriptDemo folder and run the following npm command (you’ll need to have Node.js installed) to create a file named package.json.

    4. npm init

    5. Answer the questions that are asked. For this example you can go with all of the defaults it provides. After completing the wizard a new file named package.json will be added to the root of the folder.
    6. Create the following files in the typescriptDemo folder:
      • gulpfile.js
      • gulpfile.config.js
      • tslint.json

    Installing Gulp, Gulp Modules and TSDimage

    1. Now let’s get Gulp installed globally on your machine. Open a command-prompt and run the following command:

    2. npm install gulp –g

    3. Open package.json and add the following devDependencies property into it. The location of the property in the file doesn’t really matter but I normally put it at the bottom. A sample package.json file with the dependencies already in it can be found at

      Note: The module versions shown here will certainly change over time. You can visit to find the latest version of a given module.
    4. "devDependencies": { 
          "gulp": "^3.8.11", 
          "gulp-debug": "^2.0.1", 
          "gulp-inject": "^1.2.0", 
          "gulp-sourcemaps": "^1.5.1", 
          "gulp-tslint": "^1.4.4", 
          "gulp-typescript": "^2.5.0", 
          "gulp-rimraf": "^0.1.1" 

    5. Ensure that your command window path is at the root of the typescriptDemo folder and run the following command to install the dependencies:

      npm install

    6. The site provides a Node.js module named tsd that can be used to install TypeScript type definition files that are used to provide enhanced code help in various editors. Install the tsd module globally by running the following command:

      npm install tsd@next -g

    7. Run the following command:

      tsd init

    8. Open the tsd.json file that is generated in the root of typescriptDemo and change the following properties to include “tools” in the path as shown next:

      "path": "tools/typings",
      "bundle": "tools/typings/tsd.d.ts"

    9. Let’s use tsd to install a TypeScript definition file for Angular (an angular.d.ts file) and update the tsd.json file with the Angular file details as well. Run the following command:

    10. tsd install angular --save

      Note: You can install additional type definition files for other JavaScript libraries/frameworks by running the same command but changing the name from “angular” to the appropriate library/framework. See for a list of the type definition files that are available.

  • Web Development Trends: Mobile First, Data-Oriented Development, and Single Page Applications

    I recently had the opportunity to give a keynote talk at an Intel conference about key trends in the world of Web development that I feel teams should be taking into account with projects. It was a lot of fun and I had the opportunity to talk with a lot of different people about projects they’re working on.

  • The JavaScript Cheese is Moving: Data-Oriented vs. Control-Oriented Programming

    CheeseIn a previous post I listed several of the JavaScript data binding frameworks that are available and talked about why they’re essential as applications move more and more functionality to the client. Data binding is a key aspect of client-centric programming that can significantly minimize the amount of code written, simplify maintenance, and ultimately reduce the number of bugs that crop up in an application. Without data binding you have to locate each control in a page with code and then assign or extract a value to/from it – something I call “control-oriented” programming. Here’s an example of control-oriented programming:

  • More FlipBoard Magazines: Azure, XAML, ASP.NET MVC & Web API

    In a previous post I introduced two new FlipBoard magazines that I put together including The AngularJS Magazine and The JavaScript & HTML5 Magazine. FlipBoard magazines provide a great way to keep content organized using a magazine-style format as opposed to trudging through multiple unorganized bookmarks or boring pages full of links. I think they’re really fun to read through as well.

  • Slides and Code from my AngleBrackets/DevIntersection Talks: AngularJS, ASP.NET MVC, jQuery and JavaScript

    The AngleBrackets and DevIntersection conference is all wrapped up for me and I had a great time as always meeting new people and talking about technologies that I really love to work with. Thanks to everyone that took the time to come to my talks - I definitely had a lot of fun giving them and chatting with people after each session.

comments powered by Disqus