Skip to content

Commit

Permalink
feat(src): move to @types declaration files
Browse files Browse the repository at this point in the history
PR #180

Instead of using typings, xstream now uses the @types packages for declaration files as recommended for typescript 2.0+. This also ensures compatibility with projects that used these declaration files.

This fixes #176 and compilation errors for projects using the @types declaration files such as seen in: https://gist.github.com/EnigmaCurry/c4849b25484d5068936a6818038146df
  • Loading branch information
Steelfish authored and staltz committed Apr 7, 2017
1 parent f28f8b7 commit ff2c637
Show file tree
Hide file tree
Showing 44 changed files with 102 additions and 113 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"doctest": "markdown-doctest",
"setup-browser-tests": "browserify browser-tests/index.ts -p [ tsify ] > browser-tests/tests-bundle.js",
"teardown-browser-tests": "rm browser-tests/tests-bundle.js",
"precompile": "typings install",
"compile": "tsc",
"page-content": "npm run compile && rm -rf .ignore/ && mkdirp .ignore/ && npm run changelog && node tools/make-toc.js && node tools/make-factories.js && node tools/make-methods.js && cat markdown/header.md markdown/generated-toc.md markdown/overview.md markdown/generated-factories.md markdown/generated-methods.md markdown/footer.md > .ignore/content.md",
"extra-docs": "node tools/make-extras.js && rm EXTRA_DOCS.md && cp markdown/generated-extras.md EXTRA_DOCS.md",
Expand Down Expand Up @@ -49,6 +48,9 @@
"symbol-observable": "^1.0.2"
},
"devDependencies": {
"@types/mocha": "^2.2.40",
"@types/node": "^7.0.12",
"@types/sinon": "^2.1.2",
"assert": "1.3.x",
"browserify": "13.0.x",
"commitizen": "2.9.x",
Expand All @@ -68,7 +70,6 @@
"tsify": "2.0.3",
"tslint": "4.0.2",
"typescript": "2.1.5",
"typings": "2.0.0",
"validate-commit-msg": "2.4.x"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion src/extra/fromEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="node" />
import {EventEmitter} from 'events';
import {Stream, InternalProducer, InternalListener} from '../index';

Expand Down
4 changes: 2 additions & 2 deletions tests/extra/concat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import concat from '../../src/extra/concat';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Listener, Producer} from '../../src/index';
import debounce from '../../src/extra/debounce';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/delay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import delay from '../../src/extra/delay';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/dropRepeats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream} from '../../src/index';
import fromDiagram from '../../src/extra/fromDiagram';
import dropRepeats from '../../src/extra/dropRepeats';
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/dropUntil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import dropUntil from '../../src/extra/dropUntil';
import delay from '../../src/extra/delay';
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/flattenConcurrently.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream, Listener} from '../../src/index';
import flattenConcurrently from '../../src/extra/flattenConcurrently';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/flattenSequentially.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import flattenSequentially from '../../src/extra/flattenSequentially';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/fromDiagram.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import fromDiagram from '../../src/extra/fromDiagram';
import * as assert from 'assert';
Expand Down
12 changes: 6 additions & 6 deletions tests/extra/fromEvent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import {EventEmitter} from 'events';
import fromEvent from '../../src/extra/fromEvent';
import * as assert from 'assert';
Expand Down Expand Up @@ -41,8 +41,8 @@ class FakeEventTarget implements EventTarget {

class FakeEventEmitter extends EventEmitter {
public handler: Function | undefined;
public event: string;
public removedEvent: string;
public event: string | symbol;
public removedEvent: string | symbol;

constructor() {
super();
Expand All @@ -56,13 +56,13 @@ class FakeEventEmitter extends EventEmitter {
return true;
}

addListener(e: string, handler: Function): FakeEventEmitter {
addListener(e: string, handler: Function): this {
this.event = e;
this.handler = handler;
return this;
}

removeListener(e: string, handler: Function): FakeEventEmitter {
removeListener(e: string, handler: Function): this {
this.removedEvent = e;
this.handler = void 0;
return this;
Expand Down
6 changes: 3 additions & 3 deletions tests/extra/pairwise.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import pairwise from '../../src/extra/pairwise';
import * as assert from 'assert';
Expand All @@ -23,7 +23,7 @@ describe('pairwise (extra)', () => {
assert.equal(x[0], e[0]);
assert.equal(x[1], e[1]);
} else {
assert.fail('e should be defined');
assert.fail(undefined, e, 'e should be defined', '=');
}
},
error: (err: any) => done(err),
Expand Down
18 changes: 9 additions & 9 deletions tests/extra/sampleCombine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
import xs, {Stream} from '../../src/index';
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, { Stream } from '../../src/index';
import sampleCombine from '../../src/extra/sampleCombine';
import * as assert from 'assert';

Expand All @@ -17,7 +17,7 @@ describe('sampleCombine (extra)', () => {
assert.equal(x[0], e[0]);
assert.equal(x[1], e[1]);
} else {
assert.fail('e should be defined');
assert.fail(undefined, e, 'e should be defined', '=');
}
},
error: done,
Expand All @@ -30,13 +30,13 @@ describe('sampleCombine (extra)', () => {

it('should have correct TypeScript signature', (done: any) => {
const stream1 = xs.create<string>({
start: listener => {},
stop: () => {}
start: listener => { },
stop: () => { }
});

const stream2 = xs.create<string>({
start: listener => {},
stop: () => {}
start: listener => { },
stop: () => { }
});

const combined: Stream<[string, string]> = stream1
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('sampleCombine (extra)', () => {
if (e) {
assert.equal(x[0], e[0]);
} else {
assert.fail('e should be defined');
assert.fail(undefined, e, 'e should be defined', '=');
}
},
error: done,
Expand Down
10 changes: 5 additions & 5 deletions tests/extra/split.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
import xs, {Stream} from '../../src/index';
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, { Stream } from '../../src/index';
import split from '../../src/extra/split';
import concat from '../../src/extra/concat';
import * as assert from 'assert';
Expand All @@ -24,15 +24,15 @@ describe('split (extra)', () => {
if (innerExpected) {
assert.equal(x, innerExpected.shift());
} else {
assert.fail('innerExpected should be defined');
assert.fail(undefined, innerExpected, 'e should be defined', '=');
}
},
error: (err: any) => done(err),
complete: () => {
if (innerExpected) {
assert.equal(innerExpected.length, 0);
} else {
assert.fail('innerExpected should be defined');
assert.fail(undefined, innerExpected, 'e should be defined', '=');
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/throttle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Listener, Producer} from '../../src/index';
import throttle from '../../src/extra/throttle';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/extra/tween.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream} from '../../src/index';
import tween from '../../src/extra/tween';
import * as assert from 'assert';
Expand Down
8 changes: 4 additions & 4 deletions tests/factory/combine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream} from '../../src/index';
import * as assert from 'assert';

Expand All @@ -16,7 +16,7 @@ describe('xs.combine', () => {
assert.equal(x[0], e[0]);
assert.equal(x[1], e[1]);
} else {
assert.fail('e should be defined');
assert.fail(undefined, e, 'e should be defined', '=');
}
},
error: done,
Expand Down Expand Up @@ -85,7 +85,7 @@ describe('xs.combine', () => {
if (e) {
assert.equal(x[0], e[0]);
} else {
assert.fail('e should be defined');
assert.fail(undefined, e, 'e should be defined', '=');
}
},
error: done,
Expand Down
4 changes: 2 additions & 2 deletions tests/factory/empty.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';

describe('xs.empty()', function() {
Expand Down
4 changes: 2 additions & 2 deletions tests/factory/from.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import {Promise} from 'es6-promise';
import xs, { Observable } from '../../src/index';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/factory/fromArray.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/factory/fromObservable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/factory/fromPromise.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import {Promise} from 'es6-promise';
import xs from '../../src/index';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/factory/merge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream} from '../../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/factory/never.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';

describe('xs.never()', () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/factory/of.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/factory/throw.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs from '../../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/memoryStream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../typings/globals/mocha/index.d.ts" />
/// <reference path="../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node"/>
import xs, {Listener} from '../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/operator/debug.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream, MemoryStream} from '../../src/index';
import * as assert from 'assert';
import * as sinon from 'sinon';
Expand Down
4 changes: 2 additions & 2 deletions tests/operator/drop.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream, MemoryStream} from '../../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/operator/endWhen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream, MemoryStream} from '../../src/index';
import delay from '../../src/extra/delay';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/operator/filter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream, MemoryStream} from '../../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/operator/flatten.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream, Listener} from '../../src/index';
import fromDiagram from '../../src/extra/fromDiagram';
import * as assert from 'assert';
Expand Down
4 changes: 2 additions & 2 deletions tests/operator/fold.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Stream, MemoryStream} from '../../src/index';
import * as assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions tests/operator/imitate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="../../typings/globals/mocha/index.d.ts" />
/// <reference path="../../typings/globals/node/index.d.ts" />
/// <reference types="mocha"/>
/// <reference types="node" />
import xs, {Producer, Listener, Stream, MemoryStream} from '../../src/index';
import delay from '../../src/extra/delay';
import * as assert from 'assert';
Expand Down
Loading

0 comments on commit ff2c637

Please sign in to comment.