Permalink
Browse files

feat(project): add gulp fixup-dts. removes unneeded/problematic exter…

…nal imports from d.ts

typescript complains about missing default imports for `import xy from 'xy';`
since we don't need types for those, those imports are removed from the d.ts
  • Loading branch information...
doktordirk committed Jul 4, 2016
1 parent ccfd56f commit 5d1ce6162c8bc79bf1d5cc7dc432782866239e55
Showing with 24 additions and 15 deletions.
  1. +0 −6 README.md
  2. +1 −0 build/paths.js
  3. +20 −0 build/tasks/build.js
  4. +3 −3 doc/api_rest.md
  5. +0 −6 doc/installation.md
@@ -77,12 +77,6 @@ or run
typings i github:spoonx/aurelia-api
```

Aurelia-api uses [extend](https://www.npmjs.com/package/extend). To get typings for extend run:

```sh
typings i dt~extend --global
```

## Usage

### Configuring
@@ -22,6 +22,7 @@ var paths = {
ignore: [],
useTypeScriptForDTS: false,
importsToAdd: [],
importsToIgnoreForDts: ['extend'],
sort: false
};

@@ -102,13 +102,33 @@ gulp.task('build-dts', function(){
.pipe(gulp.dest(paths.output));
});

gulp.task('fixup-dts', function(){
var importsToAdd = [];
return gulp.src(paths.output + paths.packageName + '.d.ts')
.pipe(through2.obj(function(file, enc, callback) {
file.contents = new Buffer(tools.extractImports(file.contents.toString('utf8'), importsToAdd));
this.push(file);
return callback();
}))
.pipe(insert.transform(function(contents) {
importsToAdd = importsToAdd.filter(function(line) {
return !paths.importsToIgnoreForDts.some(function(plugin) {
return line.search(plugin) !== -1;
});
});
return tools.createImportBlock(importsToAdd) + contents;
}))
.pipe(gulp.dest(paths.output));
});

gulp.task('build', function(callback) {
return runSequence(
'clean',
'build-index',
compileToModules
.map(function(moduleType) { return 'build-babel-' + moduleType })
.concat(['build-dts']),
'fixup-dts',
callback
);
});
@@ -26,9 +26,9 @@ import {Rest} from 'aurelia-api';

All methods will:

* stringify the body if it is an object and the `Content-Type` is set to `application/json` (the default).
* convert the body to querystring format if the body is an object and the `Content-Type` is set to any other value.
* leave the body unchanged if the `Content-Type` is not set or when the body is not an object.
* stringify the body, if it is an object and the `Content-Type` is set to `application/json` (the default).
* convert the body to querystring format, if the body is an object and the `Content-Type` is set to any other value.
* leave the body unchanged, if the `Content-Type` is not set or when the body is not an object.

All methods return a Promise with the server response parsed to an object if possible.

@@ -44,9 +44,3 @@ or run
```sh
typings i github:spoonx/aurelia-api
```

Aurelia-api uses [extend](https://www.npmjs.com/package/extend). To get typings for extend run:

```sh
typings i dt~extend --global
```

0 comments on commit 5d1ce61

Please sign in to comment.