TypeScript outputs JavaScript, but what are you supposed to do with it? This lesson shows how to take the output and use SystemJS as the module loader so that you can use the files in your browser.

To use system.js, first create a index.html, add system.js file from npmcdn:
https://npmcdn.com/systemjs@0.19.29/

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://npmcdn.com/systemjs@0.19.29/dist/system.js"></script>
</head>
<body> <script>
System.config({
packages: {
"dist": {
"defaultExtension": "js",
"main": "main"
}
}
}); System.import("dist")
</script>
</body>
</html>

It tell System to load the packages. Serve "dist" folder, use default extension as js, and the main entry file is main.js. Then import dist folder.

Start a server:

http-server -c-  // -c-1 -> no cache

Run:

tsc -w

To prove it do work in broswer, add console log in the code:

//main.ts

import {Two} from './two';

class Person{
constructor(){
console.log("Person!");
}
} new Two();
new Person(); // tow.ts
export class Two{
constructor(){
console.log("Two");
}
}
 

[TypeScript] Loading Compiled TypeScript Files in Browser with SystemJS的更多相关文章

  1. compiled python files

    [compiled python files] As an important speed-up of the start-up time for short programs that use a ...

  2. Couldn't import dot_parser, loading of dot files will not be possible. 解决方法

    参考: pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible ...

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

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

  4. TypeScript 1.7 & TypeScript 1.8

    TypeScript 1.7 & TypeScript 1.8 1 1 https://zh.wikipedia.org/wiki/TypeScript TypeScript是一种由微软开发的 ...

  5. nodejs + typescript + koa + eslint + typescript eslint + prettier + webstorm

    ESLint 安装 yarn add -D eslint 生成配置文件 yarn eslint --init cli 选项 How would you like to use ESLint? To c ...

  6. [TypeScript] Type check JavaScript files using JSDoc and Typescript 2.5

    Typescript 2.5 adds JSDoc type assertion support for javascript file via ts-check service. First of ...

  7. TypeScript Writing .d.ts files(编写声明文件)

    当使用扩展的JavaScript库或者插件API的时候,将需要使用声明文件(.d.ts)来描述库的类型.本文内容将包括如何编写声明文件相关的一些高级概念,然后用一些例子来展示如何将各式各样的概念与声明 ...

  8. TypeScript tsconfig.json(TypeScript配置)

    如果一个目录下存在一个tsconfig.json文件,那么意味着这个目录是TypeScript项目的根目录. tsconfig.json文件中指定了用来编译这个项目的根文件和编译选项. 一个项目可以通 ...

  9. “Compiled” Python files

    To speed up loading modules, Python caches the compiled version of each module in the __pycache__ di ...

随机推荐

  1. C语言写解一元二次方程程序心得

    前言:在网上看到不少解一元二次方程的小程序,在使用时总得出一大堆小数,感觉很不爽,遂自己重新写了一遍. 首先,先回忆一下一元二次方程的求根公式: 分别读取二次项.一次项和常数项系数并且求出delta ...

  2. 重燃你的PHP安全分析之火

    关于脚本安全这个话题好像永远没完没了,如果你经常到国外的各种各样的bugtraq上,你会发现有一半以上都和脚本相关,诸如SQL injection,XSS,Path Disclosure,Remote ...

  3. hdu 4738

    桥的应用! 虽然以前做过强联通分量的题,但刷的很水,所以比赛的时候一直想不起来是桥的应用: 反省一下~~~学习一下! 思路,找到权值最小的桥:用tarjin算法! 代码: #include<cs ...

  4. CISCO的HTTP/HTTPS/SSH配置测试完成

    按实验一步一步,倒是很容易的,也理解罗~~ START-CONFIG粗配置文件如下: r1#show run Building configuration... Current configurati ...

  5. WebApp触屏版网站开发要点

    所谓的触屏版网站其实也是WebApp的一种展示形式,主要是依赖HTML+CSS+Javascript这三个关键因素来实现,相比较原生客户端程序来说优点就是开发周期短.升级简单.维护成本低,因为从根本上 ...

  6. NAND Flash的基本操作——读、写、擦除

    基本操作 这里将会简要介绍一下NAND Flash的基本操作在NAND Flash内部是如何进行的,基本操作包括:读.写和擦除.   读:     当我们读取一个存储单元中的数据时(如图2.4),是使 ...

  7. maven 搭建企业级web项目

    就看这篇文章了:http://www.cnblogs.com/quanyongan/archive/2013/05/28/3103243.html

  8. Yii处理流程

    Yii的应用程序处理流程 用户访问URL http://www.example.com/blog/index.php?r=site/contact 1.入口脚本被网站服务器执行以处理此请求. 2.一个 ...

  9. 【HDOJ】1031 Design T-Shirt

    qsort直接排序. #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAXN ...

  10. [LeetCode#161] One Edit Distance

    Problem: Given two strings S and T, determine if they are both one edit distance apart. General Anal ...