Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
feat(project): add gulp fixup-dts. removes unneeded/problematic exter…
Browse files Browse the repository at this point in the history
…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 5d1ce61
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
6 changes: 0 additions & 6 deletions README.md
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions build/paths.js
Expand Up @@ -22,6 +22,7 @@ var paths = {
ignore: [],
useTypeScriptForDTS: false,
importsToAdd: [],
importsToIgnoreForDts: ['extend'],
sort: false
};

Expand Down
20 changes: 20 additions & 0 deletions build/tasks/build.js
Expand Up @@ -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
);
});
Expand Down
6 changes: 3 additions & 3 deletions doc/api_rest.md
Expand Up @@ -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.

Expand Down
6 changes: 0 additions & 6 deletions doc/installation.md
Expand Up @@ -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.