') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); fix(TypeScript): ensure RxJS builds with TS@next as well · ReactiveX/rxjs@f03e790 · GitHub
Skip to content

Commit f03e790

Browse files
committed
fix(TypeScript): ensure RxJS builds with TS@next as well
1 parent 0972c56 commit f03e790

4 files changed

Lines changed: 37 additions & 25 deletions

File tree

‎spec-dtslint/util/pipe-spec.ts‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,29 @@ it('should enforce types for the 9th argument', () => {
8484
consto=pipe(a('0','1'),a('1','2'),a('2','3'),a('3','4'),a('4','5'),a('5','6'),a('6','7'),a('7','8'),a('#','9'));// $ExpectError
8585
});
8686

87-
it('should return generic OperatorFunction',()=>{
87+
it('should return generic OperatorFunction 1',()=>{
88+
constcustomOperator=<T>(p: T)=>(a: Observable<T>)=>a;
89+
90+
conststaticPipe=pipe(customOperator('infer'));
91+
consto=of('foo').pipe(staticPipe);// $ExpectType Observable<string>
92+
});
93+
94+
it('should return generic OperatorFunction 2',()=>{
8895
constcustomOperator=<T>()=>(a: Observable<T>)=>a;
8996

90-
conststaticPipe=pipe(customOperator());
97+
conststaticPipe=pipe(customOperator<string>());
9198
consto=of('foo').pipe(staticPipe);// $ExpectType Observable<string>
9299
});
93100

101+
it('should return generic OperatorFunction 3',()=>{
102+
constcustomOperator=<T>()=>(a: Observable<T>)=>a;
103+
104+
// type can't be possibly be inferred here, so it's {} instead of T.
105+
conststaticPipe=pipe(customOperator());
106+
consto=of('foo').pipe(staticPipe);// $ExpectType Observable<{}>
107+
});
108+
94109
it('should return generic function',()=>{
95-
constfunc=pipe((value: string)=>value);
96-
constvalue=func("foo");// $ExpectType "foo"
110+
constfunc=pipe((value: string)=>value,(value: string)=>value+value);
111+
constvalue=func("foo");// $ExpectType string
97112
});

‎spec/operators/zipAll-spec.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ describe('zipAll operator', () => {
3535
it('should take all observables from the source and zip them',(done)=>{
3636
constexpected=['a1','b2','c3'];
3737
leti=0;
38-
of(
38+
constsource=of(
3939
of('a','b','c'),
4040
of(1,2,3)
41-
)
42-
.pipe(zipAll((a,b)=>String(a)+String(b)))
41+
).pipe(zipAll((a: string,b: number)=>a+b))
4342
.subscribe((x)=>{
4443
expect(x).to.equal(expected[i++]);
4544
},null,done);
@@ -378,7 +377,7 @@ describe('zipAll operator', () => {
378377
of('a','b','c'),
379378
of(1,2)
380379
)
381-
.pipe(zipAll((a,b)=>String(a)+String(b)))
380+
.pipe(zipAll((a: string,b: number)=>a+b))
382381
.subscribe((x)=>{
383382
expect(x).to.equal(expected[i++]);
384383
},null,done);

‎src/internal/operators/reduce.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ export function reduce<T, R>(accumulator: (acc: R, value: T, index?: number) =>
7171
};
7272
}
7373
returnfunctionreduceOperatorFunction(source: Observable<T>): Observable<R>{
74-
returnpipe(scan<T,T|R>((acc,value,index)=>{
75-
returnaccumulator(<R>acc,value,index+1);
76-
}),takeLast(1))(source)asObservable<R>;
74+
returnpipe(
75+
scan((acc: R,value: T,index: number): R=>accumulator(acc,value,index+1)),
76+
takeLast(1),
77+
)(source);
7778
};
7879
}

‎src/internal/util/pipe.ts‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import{noop}from'./noop';
2-
import{UnaryFunction,MonoTypeOperatorFunction}from'../types';
3-
import{Observable}from'../Observable';
2+
import{UnaryFunction}from'../types';
43

54
/* tslint:disable:max-line-length */
65
exportfunctionpipe<T>(): UnaryFunction<T,T>;
7-
exportfunctionpipe<T>(...operators: MonoTypeOperatorFunction<T>[]): <RextendsT>(source: Observable<R>)=>Observable<R>;
8-
exportfunctionpipe<T>(...operators: UnaryFunction<T,T>[]): <RextendsT>(source: R)=>R;
9-
exportfunctionpipe<T,A>(op1: UnaryFunction<T,A>): UnaryFunction<T,A>;
10-
exportfunctionpipe<T,A,B>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>): UnaryFunction<T,B>;
11-
exportfunctionpipe<T,A,B,C>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>,op3: UnaryFunction<B,C>): UnaryFunction<T,C>;
12-
exportfunctionpipe<T,A,B,C,D>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>,op3: UnaryFunction<B,C>,op4: UnaryFunction<C,D>): UnaryFunction<T,D>;
13-
exportfunctionpipe<T,A,B,C,D,E>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>,op3: UnaryFunction<B,C>,op4: UnaryFunction<C,D>,op5: UnaryFunction<D,E>): UnaryFunction<T,E>;
14-
exportfunctionpipe<T,A,B,C,D,E,F>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>,op3: UnaryFunction<B,C>,op4: UnaryFunction<C,D>,op5: UnaryFunction<D,E>,op6: UnaryFunction<E,F>): UnaryFunction<T,F>;
15-
exportfunctionpipe<T,A,B,C,D,E,F,G>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>,op3: UnaryFunction<B,C>,op4: UnaryFunction<C,D>,op5: UnaryFunction<D,E>,op6: UnaryFunction<E,F>,op7: UnaryFunction<F,G>): UnaryFunction<T,G>;
16-
exportfunctionpipe<T,A,B,C,D,E,F,G,H>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>,op3: UnaryFunction<B,C>,op4: UnaryFunction<C,D>,op5: UnaryFunction<D,E>,op6: UnaryFunction<E,F>,op7: UnaryFunction<F,G>,op8: UnaryFunction<G,H>): UnaryFunction<T,H>;
17-
exportfunctionpipe<T,A,B,C,D,E,F,G,H,I>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>,op3: UnaryFunction<B,C>,op4: UnaryFunction<C,D>,op5: UnaryFunction<D,E>,op6: UnaryFunction<E,F>,op7: UnaryFunction<F,G>,op8: UnaryFunction<G,H>,op9: UnaryFunction<H,I>): UnaryFunction<T,I>;
18-
exportfunctionpipe<T,A,B,C,D,E,F,G,H,I>(op1: UnaryFunction<T,A>,op2: UnaryFunction<A,B>,op3: UnaryFunction<B,C>,op4: UnaryFunction<C,D>,op5: UnaryFunction<D,E>,op6: UnaryFunction<E,F>,op7: UnaryFunction<F,G>,op8: UnaryFunction<G,H>,op9: UnaryFunction<H,I>, ...operations: UnaryFunction<any,any>[]): UnaryFunction<T,{}>;
6+
exportfunctionpipe<T,A>(fn1: UnaryFunction<T,A>): UnaryFunction<T,A>;
7+
exportfunctionpipe<T,A,B>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>): UnaryFunction<T,B>;
8+
exportfunctionpipe<T,A,B,C>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>,fn3: UnaryFunction<B,C>): UnaryFunction<T,C>;
9+
exportfunctionpipe<T,A,B,C,D>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>,fn3: UnaryFunction<B,C>,fn4: UnaryFunction<C,D>): UnaryFunction<T,D>;
10+
exportfunctionpipe<T,A,B,C,D,E>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>,fn3: UnaryFunction<B,C>,fn4: UnaryFunction<C,D>,fn5: UnaryFunction<D,E>): UnaryFunction<T,E>;
11+
exportfunctionpipe<T,A,B,C,D,E,F>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>,fn3: UnaryFunction<B,C>,fn4: UnaryFunction<C,D>,fn5: UnaryFunction<D,E>,fn6: UnaryFunction<E,F>): UnaryFunction<T,F>;
12+
exportfunctionpipe<T,A,B,C,D,E,F,G>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>,fn3: UnaryFunction<B,C>,fn4: UnaryFunction<C,D>,fn5: UnaryFunction<D,E>,fn6: UnaryFunction<E,F>,fn7: UnaryFunction<F,G>): UnaryFunction<T,G>;
13+
exportfunctionpipe<T,A,B,C,D,E,F,G,H>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>,fn3: UnaryFunction<B,C>,fn4: UnaryFunction<C,D>,fn5: UnaryFunction<D,E>,fn6: UnaryFunction<E,F>,fn7: UnaryFunction<F,G>,fn8: UnaryFunction<G,H>): UnaryFunction<T,H>;
14+
exportfunctionpipe<T,A,B,C,D,E,F,G,H,I>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>,fn3: UnaryFunction<B,C>,fn4: UnaryFunction<C,D>,fn5: UnaryFunction<D,E>,fn6: UnaryFunction<E,F>,fn7: UnaryFunction<F,G>,fn8: UnaryFunction<G,H>,fn9: UnaryFunction<H,I>): UnaryFunction<T,I>;
15+
exportfunctionpipe<T,A,B,C,D,E,F,G,H,I>(fn1: UnaryFunction<T,A>,fn2: UnaryFunction<A,B>,fn3: UnaryFunction<B,C>,fn4: UnaryFunction<C,D>,fn5: UnaryFunction<D,E>,fn6: UnaryFunction<E,F>,fn7: UnaryFunction<F,G>,fn8: UnaryFunction<G,H>,fn9: UnaryFunction<H,I>, ...fns: UnaryFunction<any,any>[]): UnaryFunction<T,{}>;
1916
/* tslint:enable:max-line-length */
2017

2118
exportfunctionpipe(...fns: Array<UnaryFunction<any,any>>): UnaryFunction<any,any>{

0 commit comments

Comments
 (0)