-
Notifications
You must be signed in to change notification settings - Fork 3k
WAITING FOR TSC 1.8: refactor(patches): move operator stubs from Observable.ts to patch files #1284
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
Conversation
Appreciate for taking effort for this! I tried this PR and found somewhat unexpected behavior, while consumption of augmented module works editor supports for typing isn't as below, none of type definitions are now being supported by editors. This change solves build time detection of what issue #1193 points but this seems quite regression that prevents daily usage of type definitions. I assume current editor's TypeScript engines are yet able to support those. |
@kwonoj Are you importing the appropriate operators? Also, could you provide a testcase I can stick in a file and play around with? |
@masaeedu That's occurring even importing full set, |
Just clarify, I'm currently using VS code. Curious if other editor / IDE might have same behavior. |
@kwonoj Weird. Trying to setup a test now. Just to be sure, have you set your |
: No, I'm using out of box configuration. Maybe that's reason? |
@kwonoj Ok, so that's probably one thing to fix. I got some great help with how to do this in microsoft/vscode#1771. However, I already have this set up and can reproduce the issue you're seeing when I The issue is that because we're not re-exporting the contents of the patch files in the |
: What happens if import operators separately? |
@kwonoj You mean if I don't use the |
: Yes, that was the case. |
When I tried both (importing Rx / importing operator individually) were not able to provide type definitions. |
So this is the scenario I'm trying right now:
The autocomplete options I get look like this: (please ignore tslint squigglies 😄). Once I change the corresponding |
@kwonoj Hopefully this is what the expected behavior is? |
Cool, it's lovely. We still need to test out couple of more editor / IDE to ensure this works though. (anyone uses other editor than VS code?) |
: I think it'd be ok as long as other editor's not regressed. losing all type intellisense is case I'd like to avoid. |
@kwonoj I can test out Atom. There's no rush to get this merged, I don't think rebasing this should be too difficult because there's not too many people fooling around with the patch files. |
@kwonoj Also, now that I've fixed the |
Thanks, let's test out couple of more and rebase. Might need see how does reexport looks like. |
: Cool, one step forward for better typing experiences :) |
I did however have to nuke the |
Nope. That was introduced due to #1010, patch operator type definition becomes empty since there's nothing exported. If there's real export, that doesn't necessarily required anymore. |
Use new external module augmentation feature to move Observable stubs into patch files. See ReactiveX#1193
Change all `import './add/operator/foo'` in Rx.ts to `export * from './add/operator/foo'`, in order to ensure the module augmentations appear in the generated Rx.d.ts file. Also remove `export var _void`s to avoid conflicts.
1905fba
to
142ebdb
Compare
What about |
@@ -1,6 +1,4 @@ | |||
import {Observable} from '../../Observable'; | |||
import {combineLatestStatic} from '../../operator/combineLatest'; | |||
|
|||
Observable.combineLatest = combineLatestStatic; | |||
|
|||
export var _void: void; |
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.
isn't this still needed? does typings contains exports after removing this?
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.
I'm not sure what you mean by that. This file is still considered an external module after removal of export var _void
if that's what you mean, because it has top level import
s.
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.
Refer #1010 I mentioned. If there isn't any export makes d.ts to be empty, it makes consumer in trouble. So question's is there anything exported after removing this and type definition's published. I assume operator includes augmentation does.
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.
@kwonoj Yes, I ran into that issue. Discussing with the TypeScript folks in microsoft/TypeScript#6022
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.
For our side of interim, we could leave this as same as before, right?
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.
Yes, that's right. I'll revert the _void: void
removals and re-exports for the observable
patches.
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.
Let's go that way. I don't think this need to block this whole PR. (export void if empty, remove if it's unnecessary)
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.
I'll be reverting these to help the PR go through, but the good news is that empty .d.ts files won't be a problem for the consumer starting in tomorrow's builds (in other words we don't need the _void: void
anymore).
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.
That's cool news, but it's starting from tomorrow's nightly version, right? thinking about discussion for min version support at #1288 (comment), that might need to be hold off for moment :(
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.
@kwonoj I guess so. I wasn't actually aware of the existence of |
buffer: (closingNotifier: Observable<any>) => Observable<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.
This may be silly but what do you think about augmenting the module before the prototype assignment?
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.
@luisgabriel I don't mind either approach. Is there a reason you prefer that style?
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.
It makes more sense to me to declare an interface first and then implement it. But this is not a big deal. I'm just commenting to see if this makes sense to someone else other than me. ;)
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.
I'd do as @luisgabriel said when I gave attempt. Honestly I think it's minor and does not impact to anything though.
: Yes, it have few additional operators in additions to Rx.
: if that works I think that'd better. I tried those while ago but wasn't able to make it. |
Does anyone know of a way that this can be applied to static methods as well? Users will still sett |
: So far I understand, augmentation's instance for class / interface and not applicable for static. |
I know, just a random item for thought. Not meant as anything to block, just maybe someone knew something. :) |
: Yup, sorry for repeating already-known-to-unknown :) Once this changes are checked in, let's track those as separate issue if needed. |
Just marking this as blocked and discussion until it's worked out. Also it needs to be rebased. |
@david-driscoll I think namespace merging might work for the static methods. |
@david-driscoll Yup, works great:
Although we should probably fix the |
Let's make static method as separate discussion. This PR itself has quite amount of changes. |
That's fine, @masaeedu you want to make a separate PR or should I? (I don't care) |
same as #1288, i'm definitely for this change but it needs to wait until the functionality is in the released TS compiler. |
Now tracked by #1388 |
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. |
Use new external module augmentation feature to move Observable stubs into patch files. See #1193