javascript - How can I use TypeScript compiler through nodejs? -
i have sample code , saved file such hello.ts
after installing nodejs on windows use below command installing typescript
npm install -g typescript
how can compile hello.ts
node.js directly?
when install "typescript 1.6 in vs2015" , use tsc.exe don't have problem want use node.js instead of vs 2015 extension
please guide me generate .js , .ds through node.js
please guide me generate .js , .ds through node.js
you have 2 options:
- run
tsc.js
node script - use
typescript
npm module
run node tsc.js
this approach taken tools e.g grunt-ts
. call spawn
on current process process.execpath
passing in other commands args (-d
).
run typescript node module
if playing typescript compiler api highly recommend ntypescript see readme reasons.
the typescript compiler provides simple function called transpile
can use expected output , write out disk yourself.
ps: have docs on typescript compiler internals here : https://basarat.gitbooks.io/typescript/content/docs/compiler/overview.html
Comments
Post a Comment