s-panferov / awesome-typescript-loader

Awesome TypeScript loader for webpack
Other
2.35k stars 179 forks source link

tsconfig `"declaration": true` doesn't produce declaration files #349

Closed quantuminformation closed 7 years ago

quantuminformation commented 7 years ago

I did this with ts-loader in the same repo and it works(produces /src)

image

chiefmc commented 7 years ago

Same here... Can't get this to work with awesome-typesctipt-loader

mblandfo commented 7 years ago

Yep. Trying to upgrade from 2.2.4 makes my .d.ts file almost empty... and 2.2.4 doesn't work with the latest typescript version: #293

MeirionHughes commented 7 years ago

pretty much having to run a separate gulp build just for the declarations; ts-loader isn't great either and cannot exlcude test files. :/

quantuminformation commented 7 years ago

Hmm I was just about to add tests with ts-loader, are you sure about this @MeirionHughes ?

quantuminformation commented 7 years ago

isn't there a spec in ts that tells tsc to ignore a file, like naming with _test in the filename?

MeirionHughes commented 7 years ago

@QuantumInformation

rules: [ { test: /\.ts?$/, exclude: [ path.resolve(__dirname, "test")], loader:"ts-loader"], ... 

... had no effect. Unfortunately, I cannot use exclude in the tsconfig because its used used by ts-node + mocha for testing. In addition: rather than get ./lib/index.d.ts I'm getting ./lib/src/index.d.ts et al

I tried getting tsc to emit only the declarations, but that didn't work. In the end, it was simply easier to gulp it:

var gulp = require('gulp');
var gulpts = require('gulp-typescript');
var typescript = require('typescript');

gulp.task('typings', () => {
  var project = gulpts.createProject('tsconfig.json', {
    typescript: typescript
  });
  return gulp.src(['src/**/*.ts']).pipe(project()).dts.pipe(gulp.dest('./lib'));
});