One of the most confusing parts of getting started with TypeScript is figuring out how to use all the libraries that you know and love from JavaScript. This lesson walks you through including Lodash in your project, installing Lodash definition files, and then properly loading Lodash with SystemJS.

install:

npm install -g typings

Excludes extra files and folder:

{
"compilerOptions": {
"rootDir": "src",
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": false,
"outDir": "./dist",
"noEmitOnError": true
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}

Install lodash:

typing install lodash --save

Import lodash:

import * as _ from 'lodash';

This time, Compiler will report error says that cannot find lodash. This is because we need to tell System.js where to find lodash.

<script>
System.config({
packages: {
"dist": {
"defaultExtension": "js",
"main": "main"
}
},
map: {
"lodash": "https://npmcdn.com/lodash@4.13.1"
}
}); System.import("dist")
</script>

Use it:

import {SocialNetwork} from './interfaces';
import * as _ from 'lodash'; class App implements SocialNetwork{
title = "Facebook"; getPeople(){
return [{name: 'John'}]
}
} console.log(_.isArray(new App().getPeople()));

[TypeScript] Using Lodash in TypeScript with Typings and SystemJS的更多相关文章

  1. 转载:TypeScript 简介与《TypeScript 中文入门教程》

    简介 TypeScript是一种由微软开发的自由和开源的编程语言.它是JavaScript的一个超集,而且本质上向这个语言添加了可选的静态类型和基于类的面向对象编程.安德斯·海尔斯伯格,C#的首席架构 ...

  2. 【TypeScript】如何在TypeScript中使用async/await,让你的代码更像C#。

    [TypeScript]如何在TypeScript中使用async/await,让你的代码更像C#. async/await 提到这个东西,大家应该都很熟悉.最出名的可能就是C#中的,但也有其它语言也 ...

  3. [TypeScript] JSON对象转TypeScript对象范例

    [TypeScript] JSON对象转TypeScript对象范例 Playground http://tinyurl.com/nv4x9ak Samples class DataTable { p ...

  4. [TypeScript] Installing TypeScript and Running the TypeScript Compiler (tsc)

    This lesson shows you how to install TypeScript and run the TypeScript compiler against a .ts file f ...

  5. 001——Typescript 介绍 、Typescript 安 装、Typescript 开发工具

    一. Typescript 介绍 1. TypeScript 是由微软开发的一款开源的编程语言. 4. TypeScript 是 Javascript 的超级,遵循最新的 ES6.Es5 规范.Typ ...

  6. TypeScript入门七:TypeScript的枚举

    关于枚举 数字枚举 字符串枚举 异构枚举 计算的和常量成员 运行时的枚举与反向映射 常量枚举与外部枚举 一.关于枚举 枚举:一个集的枚举是列出某些有穷序列集的所有成员的程序,或者是一种特定类型对象的计 ...

  7. TypeScript入门三:TypeScript函数类型

    TypeScript函数类型 TypeScript函数的参数 TypeScript函数的this与箭头函数 TypeScript函数重载 一.TypeScript函数类型 在上一篇博客中已经对声明Ty ...

  8. TypeScript入门五:TypeScript的接口

    TypeScript接口的基本使用 TypeScript函数类型接口 TypeScript可索引类型接口 TypeScript类类型接口 TypeScript接口与继承 一.TypeScript接口的 ...

  9. Typescript + TSLint + webpack 搭建 Typescript 的开发环境

    (1)初始化项目 新建一个文件夹“client-side”,作为项目根目录,进入这个文件夹: 我们先使用 npm 初始化这个项目: 这时我们看到了在根目录下已经创建了一个 package.json 文 ...

随机推荐

  1. 15个Docker基本命令及用法

    Docker入门教程:15个Docker基本命令及用法   本文中,我们将学习15个Docker命令以及命令的用法和功能,并通过实践学习它是如何工作的. AD:51CTO 网+ 第十二期沙龙:大话数据 ...

  2. linux线程(一)基本应用

    有感而发(可以直接忽略~):每次要用到线程,都要在网上重新学下基础,例子倒是不少:一种是排版好,讲的不全又不是自己想要的:一种是排版不好,直接略过了.两者兼有的又要苦苦寻找,所以还是自己总结了,觉得每 ...

  3. 设置UITextField的placeholder的颜色

    [textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];

  4. WAF

    http://netsecurity.51cto.com/art/201010/231124.htm http://wenku.baidu.com/link?url=elrFtxPRcwJ5FjlXE ...

  5. hadoop多机安装YARN

    hadoop伪分布安装称为测试环境安装,多机分布称为生成环境安装.以下安装没有进行HA(热备)和Federation(联邦).除非是性能需要,否则没必要安装Federation,HA可以一试,涉及到Z ...

  6. 【HDOJ】2853 Assignment

    最小费用最大流可解最优解.至于dif如何解,可以把w扩大100倍,如果mission编号和排列P相等则对w+1,然后建立网络流.对结果取模100可以得到没有改变mission的company数目,用c ...

  7. VS2010引用项目dll,编译时报错

    截图出处:http://www.cnblogs.com/wuhuisheng/archive/2012/02/13/2349754.html

  8. struts2错误:The Struts dispatcher cannot be found.

    struts2错误:The Struts dispatcher cannot be found. The Struts dispatcher cannot be found. This is usua ...

  9. [转]js动态创建json类型

    废话少说:json是一个特有的键值对数组类型.既然是数组类型那么我们就可以这样定义 1.先定义数组 var Data = []; 2.理解键值对 对象名:值{ "id": i, & ...

  10. Bzoj 3694: 最短路 树链剖分

    3694: 最短路 Time Limit: 5 Sec  Memory Limit: 256 MBSubmit: 67  Solved: 34[Submit][Status][Discuss] Des ...