This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +150
-0
lines changed
Expand file tree Collapse file tree 9 files changed +150
-0
lines changed Original file line number Diff line number Diff line change 1+ * .js
Original file line number Diff line number Diff line change 1+ ** Install Browserify**
2+ ```
3+ npm install -g browserify
4+ ```
5+
6+ ** Fetch dependencies**
7+ ```
8+ npm install
9+ ```
10+
11+ ** Compile .ts files**
12+ ```
13+ node node_modules/typescript/bin/tsc.js
14+ ```
15+ shortcut for this command
16+ ```
17+ npm run tsc
18+ ```
19+
20+ ** Run Browserify**
21+ ```
22+ browserify src/app.js -o bundle.js -s app
23+ ```
24+ shortcut for this command
25+ ```
26+ npm run browserify
27+
28+ ```
29+
30+ ** Start http-server**
31+ ```
32+ node node_modules/http-server/bin/http-server -o
33+ ```
34+ shortcut for this command
35+ ```
36+ npm run listen
37+ ```
38+
39+ By default http-server listens on port 8080. If this port is taken use '-p' to specify free port.
40+
41+
42+ ** Shortcut for running all steps in a batch**
43+ ```
44+ npm run all
45+ ```
Original file line number Diff line number Diff line change 1+ body
2+ {
3+ font-family : 'Segoe UI' , sans-serif
4+ }
5+
6+ span {
7+ font-style : italic
8+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+
3+ < html lang ="en " xmlns ="http://www.w3.org/1999/xhtml ">
4+ < head >
5+ < meta charset ="utf-8 " />
6+ < title > TypeScript HTML App</ title >
7+ < link rel ="stylesheet " href ="app.css " type ="text/css " />
8+ < script src ="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.1/require.min.js "> </ script >
9+ </ head >
10+ < body >
11+ < h1 > Browserify/TypeScript sample</ h1 >
12+ < div id ="content "> </ div >
13+
14+ < script >
15+ require ( [ "bundle" ] , function ( app ) {
16+ var element = document . getElementById ( "content" ) ;
17+ app . start ( function ( s ) { element . innerText = s ; } ) ;
18+ } ) ;
19+ </ script >
20+
21+ </ body >
22+ </ html >
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " typescript-browserify" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " Browserify/TypeScript demo" ,
5+ "repository" : {
6+ "type" : " git" ,
7+ "url" : " https://github.com/Microsoft/TypeScriptSamples.git"
8+ },
9+ "dependencies" : {
10+ "http-server" : " 0.8.0"
11+ },
12+ "devDependencies" : {
13+ "typescript" : " ^1.5.3"
14+ },
15+ "scripts" : {
16+ "tsc" : " node node_modules/typescript/bin/tsc.js" ,
17+ "browserify" : " browserify src/app.js -o bundle.js -s app" ,
18+ "listen" : " node node_modules/http-server/bin/http-server" ,
19+ "all" : " npm run tsc && npm run browserify && npm run listen"
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ import { TimeReporter , Printer } from './timeReporter'
2+ import { EOL } from 'os' ;
3+
4+
5+ export function start ( printer : Printer ) {
6+ let timeReporter = new TimeReporter ( printer ) ;
7+ timeReporter . start ( ) ;
8+ }
Original file line number Diff line number Diff line change 1+ declare module "os" {
2+ export var EOL : string ;
3+ }
4+
5+ declare module "util" {
6+ export function format ( format : string , ...args : any [ ] ) : string ;
7+ }
Original file line number Diff line number Diff line change 1+ import { format } from "util" ;
2+
3+ export type Printer = ( s : string ) => void ;
4+
5+ export class TimeReporter
6+ {
7+ timerToken : number ;
8+
9+ constructor ( private printer : Printer )
10+ {
11+ this . reportDate ( ) ;
12+ }
13+
14+ start ( )
15+ {
16+ this . timerToken = setInterval ( ( ) => this . reportDate ( ) , 500 ) ;
17+ }
18+
19+ stop ( )
20+ {
21+ clearTimeout ( this . timerToken ) ;
22+ }
23+
24+ reportDate ( ) {
25+ this . printer ( format ( "Date is %s" , new Date ( ) . toUTCString ( ) ) ) ;
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "module" : " CommonJS" ,
4+ "target" : " es5"
5+ },
6+ "files" : [
7+ " src/node.d.ts" ,
8+ " src/timeReporter.ts" ,
9+ " src/app.ts"
10+ ]
11+ }
You can’t perform that action at this time.
0 commit comments