From ff2c637e44cd1650545ae58c9351e5ca0de35224 Mon Sep 17 00:00:00 2001 From: Tom Bakker Date: Fri, 7 Apr 2017 09:56:04 +0200 Subject: [PATCH] feat(src): move to @types declaration files 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 --- package.json | 5 +++-- src/extra/fromEvent.ts | 2 +- tests/extra/concat.ts | 4 ++-- tests/extra/debounce.ts | 4 ++-- tests/extra/delay.ts | 4 ++-- tests/extra/dropRepeats.ts | 4 ++-- tests/extra/dropUntil.ts | 4 ++-- tests/extra/flattenConcurrently.ts | 4 ++-- tests/extra/flattenSequentially.ts | 4 ++-- tests/extra/fromDiagram.ts | 4 ++-- tests/extra/fromEvent.ts | 12 ++++++------ tests/extra/pairwise.ts | 6 +++--- tests/extra/sampleCombine.ts | 18 +++++++++--------- tests/extra/split.ts | 10 +++++----- tests/extra/throttle.ts | 4 ++-- tests/extra/tween.ts | 4 ++-- tests/factory/combine.ts | 8 ++++---- tests/factory/empty.ts | 4 ++-- tests/factory/from.ts | 4 ++-- tests/factory/fromArray.ts | 4 ++-- tests/factory/fromObservable.ts | 4 ++-- tests/factory/fromPromise.ts | 4 ++-- tests/factory/merge.ts | 4 ++-- tests/factory/never.ts | 4 ++-- tests/factory/of.ts | 4 ++-- tests/factory/throw.ts | 4 ++-- tests/memoryStream.ts | 4 ++-- tests/operator/debug.ts | 4 ++-- tests/operator/drop.ts | 4 ++-- tests/operator/endWhen.ts | 4 ++-- tests/operator/filter.ts | 4 ++-- tests/operator/flatten.ts | 4 ++-- tests/operator/fold.ts | 4 ++-- tests/operator/imitate.ts | 4 ++-- tests/operator/last.ts | 4 ++-- tests/operator/map.ts | 4 ++-- tests/operator/mapTo.ts | 4 ++-- tests/operator/remember.ts | 4 ++-- tests/operator/replaceError.ts | 6 +++--- tests/operator/startWith.ts | 4 ++-- tests/operator/take.ts | 4 ++-- tests/stream.ts | 4 ++-- tsconfig.json | 1 - typings.json | 11 ----------- 44 files changed, 102 insertions(+), 113 deletions(-) delete mode 100644 typings.json diff --git a/package.json b/package.json index 1c54644..886b81f 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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": { diff --git a/src/extra/fromEvent.ts b/src/extra/fromEvent.ts index 6319ce0..9013ece 100644 --- a/src/extra/fromEvent.ts +++ b/src/extra/fromEvent.ts @@ -1,4 +1,4 @@ -/// +/// import {EventEmitter} from 'events'; import {Stream, InternalProducer, InternalListener} from '../index'; diff --git a/tests/extra/concat.ts b/tests/extra/concat.ts index 18d5748..b6ee23e 100644 --- a/tests/extra/concat.ts +++ b/tests/extra/concat.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import concat from '../../src/extra/concat'; import * as assert from 'assert'; diff --git a/tests/extra/debounce.ts b/tests/extra/debounce.ts index 0075af2..922ae4e 100644 --- a/tests/extra/debounce.ts +++ b/tests/extra/debounce.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Listener, Producer} from '../../src/index'; import debounce from '../../src/extra/debounce'; import * as assert from 'assert'; diff --git a/tests/extra/delay.ts b/tests/extra/delay.ts index 1fbc1e9..f85da79 100644 --- a/tests/extra/delay.ts +++ b/tests/extra/delay.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import delay from '../../src/extra/delay'; import * as assert from 'assert'; diff --git a/tests/extra/dropRepeats.ts b/tests/extra/dropRepeats.ts index 6244e53..69be6b8 100644 --- a/tests/extra/dropRepeats.ts +++ b/tests/extra/dropRepeats.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream} from '../../src/index'; import fromDiagram from '../../src/extra/fromDiagram'; import dropRepeats from '../../src/extra/dropRepeats'; diff --git a/tests/extra/dropUntil.ts b/tests/extra/dropUntil.ts index 8b3e9f9..6b9abe2 100644 --- a/tests/extra/dropUntil.ts +++ b/tests/extra/dropUntil.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import dropUntil from '../../src/extra/dropUntil'; import delay from '../../src/extra/delay'; diff --git a/tests/extra/flattenConcurrently.ts b/tests/extra/flattenConcurrently.ts index f0cf7a6..fbb13ba 100644 --- a/tests/extra/flattenConcurrently.ts +++ b/tests/extra/flattenConcurrently.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, Listener} from '../../src/index'; import flattenConcurrently from '../../src/extra/flattenConcurrently'; import * as assert from 'assert'; diff --git a/tests/extra/flattenSequentially.ts b/tests/extra/flattenSequentially.ts index 52a537a..1242378 100644 --- a/tests/extra/flattenSequentially.ts +++ b/tests/extra/flattenSequentially.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import flattenSequentially from '../../src/extra/flattenSequentially'; import * as assert from 'assert'; diff --git a/tests/extra/fromDiagram.ts b/tests/extra/fromDiagram.ts index 79c6988..f5ec1f4 100644 --- a/tests/extra/fromDiagram.ts +++ b/tests/extra/fromDiagram.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import fromDiagram from '../../src/extra/fromDiagram'; import * as assert from 'assert'; diff --git a/tests/extra/fromEvent.ts b/tests/extra/fromEvent.ts index 73e38e5..11570a3 100644 --- a/tests/extra/fromEvent.ts +++ b/tests/extra/fromEvent.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import {EventEmitter} from 'events'; import fromEvent from '../../src/extra/fromEvent'; import * as assert from 'assert'; @@ -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(); @@ -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; diff --git a/tests/extra/pairwise.ts b/tests/extra/pairwise.ts index 389249c..607e621 100644 --- a/tests/extra/pairwise.ts +++ b/tests/extra/pairwise.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import pairwise from '../../src/extra/pairwise'; import * as assert from 'assert'; @@ -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), diff --git a/tests/extra/sampleCombine.ts b/tests/extra/sampleCombine.ts index 4068721..1a66e48 100644 --- a/tests/extra/sampleCombine.ts +++ b/tests/extra/sampleCombine.ts @@ -1,6 +1,6 @@ -/// -/// -import xs, {Stream} from '../../src/index'; +/// +/// +import xs, { Stream } from '../../src/index'; import sampleCombine from '../../src/extra/sampleCombine'; import * as assert from 'assert'; @@ -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, @@ -30,13 +30,13 @@ describe('sampleCombine (extra)', () => { it('should have correct TypeScript signature', (done: any) => { const stream1 = xs.create({ - start: listener => {}, - stop: () => {} + start: listener => { }, + stop: () => { } }); const stream2 = xs.create({ - start: listener => {}, - stop: () => {} + start: listener => { }, + stop: () => { } }); const combined: Stream<[string, string]> = stream1 @@ -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, diff --git a/tests/extra/split.ts b/tests/extra/split.ts index 45e6046..410acaf 100644 --- a/tests/extra/split.ts +++ b/tests/extra/split.ts @@ -1,6 +1,6 @@ -/// -/// -import xs, {Stream} from '../../src/index'; +/// +/// +import xs, { Stream } from '../../src/index'; import split from '../../src/extra/split'; import concat from '../../src/extra/concat'; import * as assert from 'assert'; @@ -24,7 +24,7 @@ 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), @@ -32,7 +32,7 @@ describe('split (extra)', () => { if (innerExpected) { assert.equal(innerExpected.length, 0); } else { - assert.fail('innerExpected should be defined'); + assert.fail(undefined, innerExpected, 'e should be defined', '='); } } }); diff --git a/tests/extra/throttle.ts b/tests/extra/throttle.ts index 85f0957..4b4b583 100644 --- a/tests/extra/throttle.ts +++ b/tests/extra/throttle.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Listener, Producer} from '../../src/index'; import throttle from '../../src/extra/throttle'; import * as assert from 'assert'; diff --git a/tests/extra/tween.ts b/tests/extra/tween.ts index fe7ebf5..1b4b295 100644 --- a/tests/extra/tween.ts +++ b/tests/extra/tween.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream} from '../../src/index'; import tween from '../../src/extra/tween'; import * as assert from 'assert'; diff --git a/tests/factory/combine.ts b/tests/factory/combine.ts index 6c83c27..8e6ef54 100644 --- a/tests/factory/combine.ts +++ b/tests/factory/combine.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream} from '../../src/index'; import * as assert from 'assert'; @@ -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, @@ -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, diff --git a/tests/factory/empty.ts b/tests/factory/empty.ts index 2416581..3b95919 100644 --- a/tests/factory/empty.ts +++ b/tests/factory/empty.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; describe('xs.empty()', function() { diff --git a/tests/factory/from.ts b/tests/factory/from.ts index 1dcb1dd..7ff135f 100644 --- a/tests/factory/from.ts +++ b/tests/factory/from.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import {Promise} from 'es6-promise'; import xs, { Observable } from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/factory/fromArray.ts b/tests/factory/fromArray.ts index ee65cb3..73aa00c 100644 --- a/tests/factory/fromArray.ts +++ b/tests/factory/fromArray.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/factory/fromObservable.ts b/tests/factory/fromObservable.ts index 8dec09f..7ac1594 100644 --- a/tests/factory/fromObservable.ts +++ b/tests/factory/fromObservable.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/factory/fromPromise.ts b/tests/factory/fromPromise.ts index 144f69f..aceb4d5 100644 --- a/tests/factory/fromPromise.ts +++ b/tests/factory/fromPromise.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import {Promise} from 'es6-promise'; import xs from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/factory/merge.ts b/tests/factory/merge.ts index dca8606..01758ae 100644 --- a/tests/factory/merge.ts +++ b/tests/factory/merge.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/factory/never.ts b/tests/factory/never.ts index 3e06e73..0bdad4c 100644 --- a/tests/factory/never.ts +++ b/tests/factory/never.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; describe('xs.never()', () => { diff --git a/tests/factory/of.ts b/tests/factory/of.ts index c8ac8cf..63a1448 100644 --- a/tests/factory/of.ts +++ b/tests/factory/of.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/factory/throw.ts b/tests/factory/throw.ts index b1f9118..be92332 100644 --- a/tests/factory/throw.ts +++ b/tests/factory/throw.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/memoryStream.ts b/tests/memoryStream.ts index edaa2d3..0bc7f2d 100644 --- a/tests/memoryStream.ts +++ b/tests/memoryStream.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Listener} from '../src/index'; import * as assert from 'assert'; diff --git a/tests/operator/debug.ts b/tests/operator/debug.ts index 2a90e1d..9883ef0 100644 --- a/tests/operator/debug.ts +++ b/tests/operator/debug.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; import * as sinon from 'sinon'; diff --git a/tests/operator/drop.ts b/tests/operator/drop.ts index d4053a0..97ff077 100644 --- a/tests/operator/drop.ts +++ b/tests/operator/drop.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/operator/endWhen.ts b/tests/operator/endWhen.ts index f4d7794..4706c13 100644 --- a/tests/operator/endWhen.ts +++ b/tests/operator/endWhen.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import delay from '../../src/extra/delay'; import * as assert from 'assert'; diff --git a/tests/operator/filter.ts b/tests/operator/filter.ts index 1f045bd..1d0970b 100644 --- a/tests/operator/filter.ts +++ b/tests/operator/filter.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/operator/flatten.ts b/tests/operator/flatten.ts index 08b4288..152b4d0 100644 --- a/tests/operator/flatten.ts +++ b/tests/operator/flatten.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, Listener} from '../../src/index'; import fromDiagram from '../../src/extra/fromDiagram'; import * as assert from 'assert'; diff --git a/tests/operator/fold.ts b/tests/operator/fold.ts index a190287..39ea11d 100644 --- a/tests/operator/fold.ts +++ b/tests/operator/fold.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/operator/imitate.ts b/tests/operator/imitate.ts index f71c47e..bea9f36 100644 --- a/tests/operator/imitate.ts +++ b/tests/operator/imitate.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Producer, Listener, Stream, MemoryStream} from '../../src/index'; import delay from '../../src/extra/delay'; import * as assert from 'assert'; diff --git a/tests/operator/last.ts b/tests/operator/last.ts index 416e20b..f646057 100644 --- a/tests/operator/last.ts +++ b/tests/operator/last.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/operator/map.ts b/tests/operator/map.ts index 599d0f2..5fdb78c 100644 --- a/tests/operator/map.ts +++ b/tests/operator/map.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/operator/mapTo.ts b/tests/operator/mapTo.ts index 5cf2f4c..7b81696 100644 --- a/tests/operator/mapTo.ts +++ b/tests/operator/mapTo.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/operator/remember.ts b/tests/operator/remember.ts index 17367a3..377f798 100644 --- a/tests/operator/remember.ts +++ b/tests/operator/remember.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; function noop() {}; diff --git a/tests/operator/replaceError.ts b/tests/operator/replaceError.ts index b26a939..4a5031b 100644 --- a/tests/operator/replaceError.ts +++ b/tests/operator/replaceError.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream, Producer} from '../../src/index'; import * as assert from 'assert'; @@ -40,7 +40,7 @@ describe('Stream.prototype.replaceError', () => { while (events.length > 0) { const event = events.shift(); if (!event) { - assert.fail('event should not be undefined'); + assert.fail(undefined, event, 'event should not be undefined', '='); } else { switch (event.type) { case 'next': listener.next(event.value); break; diff --git a/tests/operator/startWith.ts b/tests/operator/startWith.ts index c1b1e2e..0f730c0 100644 --- a/tests/operator/startWith.ts +++ b/tests/operator/startWith.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {MemoryStream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/operator/take.ts b/tests/operator/take.ts index 8fb10a7..1f0e1e0 100644 --- a/tests/operator/take.ts +++ b/tests/operator/take.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Stream, MemoryStream} from '../../src/index'; import * as assert from 'assert'; diff --git a/tests/stream.ts b/tests/stream.ts index c58b32c..72e3312 100644 --- a/tests/stream.ts +++ b/tests/stream.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// import xs, {Producer, Listener, Stream} from '../src/index'; import fromDiagram from '../src/extra/fromDiagram'; import * as assert from 'assert'; diff --git a/tsconfig.json b/tsconfig.json index b4b3e80..250596b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,7 +23,6 @@ "tabSize": 2 }, "files": [ - "typings/index.d.ts", "src/extra/concat.ts", "src/extra/debounce.ts", "src/extra/delay.ts", diff --git a/typings.json b/typings.json deleted file mode 100644 index 75b0e7a..0000000 --- a/typings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "xstream", - "dependencies": {}, - "devDependencies": { - "sinon": "registry:npm/sinon#1.16.0+20160427193336" - }, - "globalDevDependencies": { - "mocha": "github:DefinitelyTyped/DefinitelyTyped/mocha/mocha.d.ts#d6dd320291705694ba8e1a79497a908e9f5e6617", - "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#20e1eb9616922d382d918cc5a21870a9dbe255f5" - } -}