Skip to content

Ambient declarations for use underscore.js with typescript

Notifications You must be signed in to change notification settings

alvivi/typescript-underscore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Underscore ambient declarations for TypeScript

underscore.js is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js, but without extending any of the built-in JavaScript objects.

Underscore provides 80-odd functions that support both the usual functional suspects: map, select, invoke — as well as more specialized helpers: function binding, javascript templating, deep equality testing, and so on. It delegates to built-in functions, if present, so modern browsers will use the native implementations of forEach, map, reduce, filter, every, some and indexOf.

These ambient declaration source files add statically type information for use underscore.js in TypeScript.

Usage

To use underscore.js in the browser just add a reference comment on the top of the sources that use underscore.

/// <reference path="underscore.browser.d.ts" />

console.log(_.range(10));

If you are using underscore.js in a node.js environment, then you have to add a reference comment and import the underscore module where you need it.

/// <reference path="underscore.d.ts" />

import _ = module("underscore");
console.log(_.range(10));

You can also use this syntax on a browser through require.js.

About

Ambient declarations for use underscore.js with typescript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published