git clone 'https://github.com/vbauer/lein-typescript.git'

(ql:quickload :vbauer.lein-typescript)


Build Status Clojars Project

TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict superset of JavaScript, and adds optional static typing and class-based object-oriented programming to the language. - Wikipedia

lein-typescript is a Leiningen plugin that allows to use TypeScript compiler.


Install NodeJS and NPM (package manager for Node) to install TypeScript:


Install TypeScript to use lein-typescript plugin. It could be done in few ways:

To enable lein-typescript for your project, put the following in the :plugins vector of your project.clj file:

; Use latest version instead of "X.X.X"
:plugins [[lein-typescript "X.X.X"]]


To configure lein-typescript, put the :typescript parameter in the file project.clj. It could be a single configuration (simple map) or a collection of configurations (for multiple configuration).

:typescript {
  :sources ["*.ts" "resources/*.ts"]
  :excludes ["bad.ts"]
  :out "app.js"
  :declaration true
  :remove-comments true
  :target :es5

Configuration parameters

List of input TypeScript sources. It is possible to use a single source or a vector of sources. To configure this parameter, you could also use a Glob Patterns.
List of glob patterns to prevent processing of some files. It is also possible to use both variants: single pattern and collection of patterns.
Redirect output structure to the specified directory (it is undefined by default). ":out" parameter will be used in priority.
Concatenate and emit output to single file which you can specify using this parameter (it is undefined by default).
Do not emit comments to output (default value is "false").
Generates corresponding ".d.ts" file (default value is "false").
Generates corresponding '.map' file (default is "false").
Specify module code generation: :commonjs or :amd (it is undefined by default).
Specify ECMAScript target version: :es3 (default), :es5, or :es6 (experimental).
Watch input files. It could be helpful to use this parameter with lein-pdo and/or with separate profile (default is "false").


To enable this plugin in the compile stage, use the following hook: clojure :hooks [lein-typescript.plugin]


To compile TypeScript files using configuration from project.clj, you should use: lein typescript. It is also possible to use short alias for typescript task: lein ts.

To show help: lein help typescript

Example project

Just clone the current repository and try to play with example project for better understanding how to use lein-typescript.

Thanks to

Microsoft Corporation, Anders Hejlsberg and TypeScript community for the great programming language.

Might also like


Copyright © 2015 Vladislav Bauer

Distributed under the Eclipse Public License, the same as Clojure.