javascript - Invoking TypeScript compiler as NPM module - Stack Overflow

I have a project written in TypeScript and I use a task runner for building (whatever: Gulp, Jake, etc.

I have a project written in TypeScript and I use a task runner for building (whatever: Gulp, Jake, etc.). The TypeScript piler i use is the one I installed from NPM:

npm install typescript

Important: As you can see there is no global -g parameter and this is on purpose. As I need to use a specific version of the piler with some modifications.

Calling tsc programmatically

So I want to invoke the piler from my Javascript file configuring my task manager:

var tsc = require("typescript");

function pile() {
  tscpile(...); // I would like to do something like this
}

Can I do that? I have tried, but not getting much luck so far.

I have a project written in TypeScript and I use a task runner for building (whatever: Gulp, Jake, etc.). The TypeScript piler i use is the one I installed from NPM:

npm install typescript

Important: As you can see there is no global -g parameter and this is on purpose. As I need to use a specific version of the piler with some modifications.

Calling tsc programmatically

So I want to invoke the piler from my Javascript file configuring my task manager:

var tsc = require("typescript");

function pile() {
  tsc.pile(...); // I would like to do something like this
}

Can I do that? I have tried, but not getting much luck so far.

Share Improve this question edited Aug 12, 2016 at 21:29 Andry asked Aug 12, 2016 at 21:17 AndryAndry 16.9k30 gold badges156 silver badges265 bronze badges 2
  • Have a look at gulp-typescript – Aleksey L. Commented Aug 14, 2016 at 5:19
  • I think this is what you are looking for – Jthorpe Commented Jan 22, 2022 at 0:53
Add a ment  | 

1 Answer 1

Reset to default 6

You sure can. There are numerous tools - tsify, ts-node, ts-loader - that are built using the TypeScript Compiler API.

However, it's a little bit more plicated than a single pile call.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744800513a4594462.html

相关推荐

  • javascript - Invoking TypeScript compiler as NPM module - Stack Overflow

    I have a project written in TypeScript and I use a task runner for building (whatever: Gulp, Jake, etc.

    2天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信