TypeScriptã®ã³ã³ãã¤ã«ã¯é ããã©ãããã§ãgrunt-typescriptãæéãããªãã ãããï¼
ãã®å 容㯠grunt-typescript 0.3.2 (typescript 1.0.0) ããã¨ã«è¨è¿°ãã¦ãã¾ãã
ã¤ããã£ã grunt-typescript 0.3.2 ããªãªã¼ã¹ããããã§ãããã¡ãã£ã¨ã³ã³ãã¤ã«ãæ©ããã¦ã¿ã¾ãããã£ã¦ãã¨ã§ typescript èªä½ã®ã³ã³ãã¤ã«ã®éãã tsc ã¨æ¯è¼ãã¦è¦ã¾ããã
grunt-typescript ã¯ä»¥ä¸ã®ããã«æå®ãã¦ã¾ãã
typescript:{ base:{ src: ["src/compiler/tsc.ts"] } }
ã¾ã㯠tsc ã³ãã³ãã
$ time tsc src/compiler/tsc.ts real 0m15.641s user 0m0.000s sys 0m0.015s
ã§ããã¤ã¯ç§ã®ç°å¢ã Windows 㧠Visual Studio 2013 ã® Update 2 RC ãå½ãã£ã¦ãç¶æ ãªã®ã§ããã® tsc ã³ãã³ã㯠WSH ã§åãã¦ã¦ãnode ã§åãã¦ãªãã§ãããªã®ã§ãnode ã§åãããã« ntsc ã£ã¦ã³ãã³ãä½ã£ã¦ãã¡ãã§ã試ãã¦ã¿ã¾ãããå é¨çã«ã¯ node ã³ãã³ã㧠tsc.js ãå¼ãã§ãã ãã§ãã
$ time ntsc src/compiler/tsc.ts real 0m15.543s user 0m0.030s sys 0m0.030s
0.1ç§ãããæ©ããã§ãããå®å ¨ã«èª¤å·®ã®ç¯å²ã§ããã
æå¾ã« grunt-typescript ã
$ time grunt typescript:base Running "typescript:base" (typescript) task 117 files created. js: 117 files, map: 0 files, declaration: 0 files (13875ms) Done, without errors. real 0m14.700s user 0m0.015s sys 0m0.060s
grunt-typescript ã®ã»ãã 1 ç§ãããæ©ãã§ãã
ãªãæ©ããªã£ã¦ããã
grunt-typescript ã¯åºæ¬çã«ã¯ tsc.ts ã®ã³ã¼ããåèã«ä½ã£ã¦ã¦ãå°ã Grunt ç¨ã®å¦çãããã¦ä½ã£ã¦ã¾ãããªã®ã§ tsc ãç´æ¥å®è¡ããã®ã«ããã¹ã¦è¥å¹²é ããªããããã§ãããã§ãä»å(å®éã¯0.3.0ãã)ã¡ãã£ã¨å é¨å¦çã«æãåºãã¦ãé度ã¢ãããã¯ãã£ã¦ã¿ã¾ããã
tsc ã¯ã³ã³ãã¤ã«ã®ã¹ãããã¨ãã¦åãã¡ã¤ã«ãã¨ã«ãã£ããæ¸ã㨠Syntax ã®ãã§ãã¯ã Semantic ã®ãã§ãã¯ã JS ã®çæã d.ts ã®çæã¨ãã£ã¦ããã®ã§ããããã® Syntax ã®ãã§ãã¯ã¨ãSemantic ã®ãã§ãã¯ã§ãããlib.d.ts ã«ã¤ãã¦ãå®è¡ãã¦ãã¾ããã§ããã lib.d.ts ã£ã¦ typescript ã®çµã¿è¾¼ã¿ã¿ãããªãã®ã§ããããã syntax ã semantic ã«ã¨ã©ã¼ããã£ããé§ç®ã§ãåæã¨ãã¦ãã§ãã¯ããªãã£ã¦ãåé¡ãªãã¯ããªã®ã§ã lib.d.ts ã対象ããå¤ãããã«ãã¾ããã lib.d.ts ãã¡ã¤ã«ã¯çµæ§å¤§ããªãã¡ã¤ã«ãªã®ã§ããããå¤ããã¨ã§ 1 ç§ããã稼ãã¾ããã
ã¡ãªã¿ã«ã grunt-typescript 0.3.1 㧠lib.d.ts ã« syntax ãã§ãã¯ã¨ semantic ãã§ãã¯ããå«ãããã«ããã以ä¸ã®å®è¡é度ã§ããã
$ time grunt typescript:base Running "typescript:base" (typescript) task 117 files created. js: 117 files, map: 0 files, declaration: 0 files (15373ms) Done, without errors. real 0m16.190s user 0m0.030s sys 0m0.031s
ä»å¾ typescript ã®å
é¨æ§é ãå¤æ´ããããåããªããªãå¯è½æ§ãããã®ã§å°ãæãã¨ãããããã®ã§ãããããã
ã¨ãããã lib.d.ts ã ES3 ã®ã¿ã¨ã ES5 ã®ã¿ã¨ã HTML DOMç¨ã¨ãã®ä½ç¨®é¡ãã«åãã¦ãããããã£ã¨å¬ããã®ã§ããããªã¯ã¨ã¹ãã§ãæãã¦ã¿ãããããã
ããã«æ©ã watch ãªãã·ã§ã³ ã使ã£ã2åç®ä»¥éã®ã³ã³ãã¤ã«
ããã« watch ãªãã·ã§ã³ã§ãã¡ã¤ã«ç£è¦ãã¦ããã¨ãã®2åç®ä»¥éã®ã³ã³ãã¤ã«ã¯ãå¤æ´ããããã¡ã¤ã«ã®ã¿èªã¿è¾¼ã¿ã¨æ¸ãåºããããã®ã§ããã«æ©ãã§ãã以ä¸ã®ãããªæãã
$ grunt typescript:watch Running "typescript:watch" (typescript) task Watching directory.... c:\Work\Git\typescript\src\compiler >> Changed c:/Work/Git/typescript/src/compiler/tsc.ts 117 files created. js: 117 files, map: 0 files, declaration: 0 files (14036ms) Watching directory.... c:\Work\Git\typescript\src\compiler >> Changed c:/Work/Git/typescript/src/compiler/tsc.ts 1 file created. js: 1 file, map: 0 files, declaration: 0 files (8761ms) Watching directory.... c:\Work\Git\typescript\src\compiler
tsc.tsã試ãã«å¤æ´-ä¿åãã¦çµæã®ã¨ããã確èªããã¨ã1åç®ã¯117ãã¡ã¤ã«ãåºåããã¦ãã¾ããã2åç®ã¯1ãã¡ã¤ã«ã®ã¿ãåºåããã¦ãã¾ããããã¡ã¤ã«ã®å¤æ´æ¥ä»ã確èªãã¦ããã®ã§è¤æ°ãã¡ã¤ã«æ´æ°ããããããã®ãã¡ã¤ã«æ°åã ã対象ã«ãã¾ããå®è¡é度ã«ã¤ãã¦ã大ä½6ç§ã»ã©æ©ããªã£ã¦ã¾ãããããã¯å¯¾è±¡ã¨ãªã£ã¦ããªããã¡ã¤ã«ã¯èªã¿è¾¼ã¿ã¨æ¸ãåºããå®æ½ãã¦ããªãã®ã¯æ¸ããéãã§ãããããã ãã§ã¯ãªããå ã«æ¸ããã³ã³ãã¤ã«ã®ã¹ãããã® JS ã®çæãå¤ãã¦ããããã§ãã
ãã ããåä¸ãã¡ã¤ã«ã§åºåãã tsc ã§ããã¨ããã® --out ãªãã·ã§ã³ãã¤ãã¦ããç¶æ ã 㨠lib.d.ts ãå¤ãã¦ããæ©æµã ããªã®ã§ããã¾ã§ã¯éããªããªãã®ã§ãããã¾ããããã§ã tsc ã³ãã³ããå©ããããã¯ã³ã³ãã¤ã«ãæ©ããªããã¨ã
ã¨ãããã¾ã§æ¸ã㦠Syntax ã®ãã§ãã¯ã¨ã Semantic ã®ãã§ãã¯ããããªããããªæ°ããã¦ãã¾ããã"対象ã«ãªã£ã¦ããªã = å ã®çµæã¨åã" ãªã¯ããªã®ã§ã¤ã±ãããªæ°ããã¾ããã¡ãã£ã¨ç¢ºèªãã¦ã¿ããããã