[TypeScript] Using Typings and Loading From node_modules
Using TypeScript when installing packages from npm often requires you to install related definition files. This lesson shows you how to use typings to install es6-shim then how to configure SystemJS to load from node_modules.
Install:
npm install --save rxjs
Import:
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/interval';
But you will find errors, the reason for that rxjs include es6, but our target is es5.
So, install:
typings install es6-shim --save -ambient
Include:
<script>
System.config({
packages: {
"dist": {
"defaultExtension": "js",
"main": "main"
},
"rxjs": {
"defaultExtension": "js"
}
},
map: {
"lodash": "https://npmcdn.com/lodash@4.13.1",
"rxjs": "node_modules"
}
}); System.import("dist")
</script>
Then you can start using rxjs;
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/interval';
Observable.interval(1000)
.subscribe( x => console.log(x))
[TypeScript] Using Typings and Loading From node_modules的更多相关文章
- [TypeScript] Using Lodash in TypeScript with Typings and SystemJS
One of the most confusing parts of getting started with TypeScript is figuring out how to use all th ...
- 在 Typescript 2.0 中使用 @types 类型定义
在 Typescript 2.0 中使用 @type 类型定义 基于 Typescript 开发的时候,很麻烦的一个问题就是类型定义.导致在编译的时候,经常会看到一连串的找不到类型的提示.解决的方式经 ...
- Nodejs生态圈的TypeScript+React
基于Nodejs生态圈的TypeScript+React开发入门教程 基于Nodejs生态圈的TypeScript+React开发入门教程 概述 本教程旨在为基于Nodejs npm生态圈的前端程 ...
- 基于Nodejs生态圈的TypeScript+React开发入门教程
基于Nodejs生态圈的TypeScript+React开发入门教程 概述 本教程旨在为基于Nodejs npm生态圈的前端程序开发提供入门讲解. Nodejs是什么 Nodejs是一个高性能Ja ...
- TypeScript 素描 - 模块解析、声明合并
模块解析 模块解析有两种方式 相对方式 也就是以/或 ./或-/开头的,比如import jq from "/jq" 非相对方式 比如 import model from ...
- 搭建typescript开发环境最详细的全过程
搭建typescript开发示例https://github.com/Microsoft/TypeScriptSamples typescript案例https://www.tslang.cn/sam ...
- 在微信小程序开发中使用Typescript
Typescript的优势咱不需要赘述太多,有兴趣可以参考(https://www.typescriptlang.org/).今天给大家分享一下如何在微信小程序(或者其他同类小程序)开发中使用Type ...
- Angular2 从0到1 (一)
史上最简单Angular2教程,大叔都学会了 作者:王芃 wpcfan@gmail.com 第一节:Angular 2.0 从0到1 (一)第二节:Angular 2.0 从0到1 (二)第三节:An ...
- Angular2学习
1.新建项目 2.新建Model public class TodoItem { public int Id { get; set; } public string Key { get; set; } ...
随机推荐
- .net source code
.NET 类库的强大让我们很轻松的解决常见问题,作为一个好专研的程序员,为了更上一层楼,研究CLR的基础类库实现是快速稳定的捷径. 一般场景下,采用 Reflector可以反射出.NET 的部分实现出 ...
- isEqual
"; NSString *str2 = [NSString stringWithFormat:@"%@", str1]; 大家明白, str1和str2在内存中的地址是不 ...
- html多行注释方法
Html单行:<!-- -->多行:<!-- -->javascript单行://多行:/* */Vbscript单行:'多行:'ASP <% %>中: 单行:' ...
- Kaggle Competition Past Solutions
Kaggle Competition Past Solutions We learn more from code, and from great code. Not necessarily alwa ...
- Android-x86虚拟机安装配置全攻略
转自Android-x86虚拟机安装配置全攻略 注:这里安装从简,具体请参考虚拟机Vmware安装运行安卓4.0详细教程 Android-x86虚拟机安装配置网上有很多,但是全部说明白的确不多,希望这 ...
- Python还是很重要的,不能丢。学习IF和WHILE
number = 23 guess = int(input('Enter an interger : ')) if guess == number: print('Congratulations, y ...
- [转贴]JAVA :CXF 简介
Apache CXF = Celtix + XFire,Apache CXF 的前身叫 Apache CeltiXfire,现在已经正式更名为 Apache CXF 了,以下简称为 CXF.CXF 继 ...
- 更好的 SQL 模式的 10 条规则
更好的 SQL 模式的 10 条规则 2015-06-17 11:57:392353浏览1评论 在创建新表和数据仓库时,要做很多决定.一些在当时似乎无关紧要的地方,却让你和用户在数据库的生命期内感到痛 ...
- hadoop多机安装HA+YARN
HA 相比于Hadoop1.0,Hadoop 2.0中的HDFS增加了两个重大特性,HA(热备)和Federation(联邦).HA即为High Availability,用于解决NameNode单点 ...
- 【HDOJ】2133 What day is it
需要注意数据有效性. #include <stdio.h> #define isLeapYear(y) (y%4==0&&y%100!=0)||(y%400==0) ][] ...