Skip to content
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

chore(typings): added typings for minor operators cache, catch, debou… #1352

Closed
wants to merge 1 commit into from

Conversation

david-driscoll
Copy link
Member

…nce, etc


Will need to be rebased after #1351

@david-driscoll david-driscoll force-pushed the typings/misc branch 3 times, most recently from c816f1c to a3c7f91 Compare February 14, 2016 16:50
@@ -0,0 +1,10 @@
import {Observable, ObservableInput} from '../Observable';

export type _mapProject<T, R> = (value: T, index: number) => R;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these need to start with _?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these input types could be a separate PR as it's not a dependency for creating the *Signature interfaces.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be, in that case those new PR should be checked in prior to this though.

  • is `util' feasible place for these? (I'm also not sure)
  • as above comment, does _ needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this by myself and found it's indifferent to have _ or not, by this are actually not being exposed as pubic type definition. If intention is to use idiom of non-exposed export, I'm ok with this. Up to you. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing though, as other signature does I'd like to suggest name these such as predicateSignature, etcs to have clarity since it's not actual predicate but signature of predicate. Any suggestions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just rip them out for now, just easier than splitting hairs. 👍

@david-driscoll david-driscoll force-pushed the typings/misc branch 2 times, most recently from e87f4fd to 0006170 Compare February 21, 2016 22:47
@@ -2,6 +2,6 @@
import {Observable} from '../../Observable';
import {first} from '../../operator/first';

Observable.prototype.first = first;
Observable.prototype.first = <any>first;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying over my comment I guess; is this not assignable as is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without it there was a compiler error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracing it back, it looks like it's because you have an overload in FirstSignature with a void parameter. I don't think its possible to pass an argument of type void in TypeScript, so that overload can't be called. Changing to any makes it compile again, although I don't understand what use case that second overload satisfies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It lets you supply null / undefined and skip the R argument. see example.
Now it does look like that last overload shouldn't be <T | R> but just <R>, I'll try and fix that tomorrow morning.

@kwonoj
Copy link
Member

kwonoj commented Feb 22, 2016

Change looks good to me, might need response for @masaeedu 's comment only. Will leave this until question's fully resolved before check this in.

@david-driscoll
Copy link
Member Author

Fixed up first/last so that the default value is R when using the selector and T when not using the selector.

@kwonoj
Copy link
Member

kwonoj commented Feb 24, 2016

Will check in this around tomorrow. /cc @masaeedu for visibility to see if there's other suggestions before check this ins.

@@ -17,11 +17,18 @@ import {EmptyError} from '../util/EmptyError';
* @throws - Throws if no items that match the predicate are emitted by the source Observable.
*/
export function last<T, R>(predicate?: (value: T, index: number, source: Observable<T>) => boolean,
resultSelector?: (value: T, index: number) => R,
defaultValue?: R): Observable<T> | Observable<R> {
resultSelector?: (value: T, index: number) => R | void,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be changed to _mapProject? I think the compiler is interpreting the return type as R | void, rather than the interpreting the whole argument as predicate | void. If this is what it's supposed to be, the last overload in the interface below should be updated from _mapProject.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought projection signature (like _mapProject) was taken out in this PR to be dealt separately, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwonoj Whoops, that's right. I was looking at the squashed changes. The fix here would instead be to add parens like so: ((value: T, index: number) => R) | void

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, since those to be dealt with projection signature in later, I assume it'd good to kick off this PR to be checked in first - what do you think? @masaeedu

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@masaeedu
Copy link
Contributor

LGTM. Some minor quibbles with the function signatures that have to be cast to <any>, but users don't really see those.

@kwonoj
Copy link
Member

kwonoj commented Feb 24, 2016

Merged with 9b9b2de, appreciate @david-driscoll !

@kwonoj kwonoj closed this Feb 24, 2016
@lock
Copy link

lock bot commented Jun 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants