TypeStrong / tsify

Browserify plugin for compiling TypeScript
344 stars 75 forks source link

how to select which files to compile? #260

Closed SET001 closed 4 years ago

SET001 commented 4 years ago

following the example on readme I created such a gulp task that should compile my index.ts

task('compile', () =>
  browserify()
    .add('./src/index.ts')
    .plugin(tsify, { noImplicitAny: true })
    .bundle()
    .on('error', errorHandler)
    .pipe(dest('./dist'))

however, for some reason. I'm getting errors from other files which are not included in index.tx. Seems like tsify is compiling all *.ts files. How can I stop it from doing that? How can I make it to compile only index.ts and all files that are imported from there?

cartant commented 4 years ago

From the docs:

tsify supports overriding the files, exclude and include options. In particular, if "files": [] is specified, only the Browserify entry points (and their dependencies) are passed to TypeScript for compilation.

So this should work:

task('compile', () =>
  browserify()
    .add('./src/index.ts')
    .plugin(tsify, { noImplicitAny: true, files: [] })
    .bundle()
    .on('error', errorHandler)
    .pipe(dest('./dist'))

But I don't use Gulp, I've not used tsify for a long time and I've always used tsify in conjunction with a tsconfig.json file. Regarding the latter, I would not recommend using it without a tsconfig.json file, as there are too many compiler options and the defaults are not sensible - not strict, etc.

SET001 commented 4 years ago

yeah, that works fine. Thanx.