-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): improve type signatures #58
Conversation
BREAKING CHANGES: DriverFn is now a Generic. Sources and Sinks types are always objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good.
@@ -51,6 +51,7 @@ | |||
} | |||
}, | |||
"devDependencies": { | |||
"@motorcycle/tslint": "1.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
"tslint": "^4.0.0-dev.1", | ||
"typescript": "^2.1.0-dev.20161109", | ||
"tslint": "^4.1.1", | ||
"typescript": "^2.1.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
[key: string]: T; | ||
} | ||
|
||
export interface Component<Sources extends Object<Source>, Sinks extends Object<Sink<any>>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
@@ -4,19 +4,23 @@ import { Subject, sync, next, error, complete } from 'most-subject'; | |||
export type Sink<T> = Stream<T>; | |||
export type Source = any; | |||
|
|||
export interface Component<Sources, Sinks> { | |||
export interface Object<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
export interface DriverFn { | ||
<T, R>(sink: Sink<T>): R; | ||
export interface DriverFn<T, R> { | ||
(sink: Sink<T>): R; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
@@ -53,7 +57,7 @@ function callDrivers<Sources, Sinks> (drivers: Drivers, sinkProxies: Sinks): Sou | |||
}, {} as Sources); | |||
} | |||
|
|||
function callComponent<Sources, Sinks> ( | |||
function callComponent<Sources extends Object<Source>, Sinks extends Object<Source>> ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
@@ -130,7 +130,7 @@ describe('Motorcycle Core', () => { | |||
|
|||
it('prints errors to the console', (done) => { | |||
const sandbox = sinon.sandbox.create(); | |||
sandbox.stub(console, `error`); | |||
const stub = sandbox.stub(console, `error`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
@@ -143,7 +143,7 @@ describe('Motorcycle Core', () => { | |||
Motorcycle.run(main, {other: driver}); | |||
|
|||
setTimeout(() => { | |||
sinon.assert.calledOnce(console.error as Sinon.SinonSpy); | |||
sinon.assert.calledOnce(stub); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
"check-operator", | ||
"check-separator", | ||
"check-type"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
"check-separator", | ||
"check-type"] | ||
} | ||
"extends": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
Improves the Type Signatures of
DriverFn
,Sources
, andSinks
.BREAKING CHANGES: DriverFn is now a Generic. Sources and Sinks types are always objects.