Skip to content

Commit aef9ed3

Browse files
committed
Fix weird rxjs operator typing issue
1 parent 6a6f269 commit aef9ed3

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/cdk/rxjs/rx-operators.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,21 @@ export type debounceTimeOperatorType<T> = typeof debounceTimeOperator & Debounce
104104
export type auditTimeOperatorType<T> = typeof auditTimeOperator & AuditTimeBrand;
105105
export type takeUntilOperatorType<T> = typeof takeUntilOperator & TakeUntilBrand;
106106

107-
108-
export const finallyOperator = _finallyOperator as typeof _finallyOperator & FinallyBrand;
109-
export const catchOperator = _catchOperator as typeof _catchOperator & CatchBrand;
110-
export const doOperator = _doOperator as typeof _doOperator & DoBrand;
111-
export const map = mapOperator as typeof mapOperator & MapBrand;
112-
export const filter = filterOperator as typeof filterOperator & FilterBrand;
113-
export const share = shareOperator as typeof shareOperator & ShareBrand;
114-
export const first = firstOperator as typeof firstOperator & FirstBrand;
115-
export const switchMap = switchMapOperator as typeof switchMapOperator & SwitchMapBrand;
116-
export const startWith = startWithOperator as typeof startWithOperator & StartWithBrand;
117-
export const debounceTime = debounceTimeOperator as typeof debounceTimeOperator & DebounceTimeBrand;
118-
export const auditTime = auditTimeOperator as typeof auditTimeOperator & AuditTimeBrand;
119-
export const takeUntil = takeUntilOperator as typeof takeUntilOperator & TakeUntilBrand;
107+
// We add `Function` to the type intersection to make this nomically different from
108+
// `finallyOperatorType` while still being structurally the same. Without this, TypeScript tries to
109+
// reduce `typeof _finallyOperator & FinallyBrand` to `finallyOperatorType<T>` and then fails
110+
// because `T` isn't known.
111+
export const finallyOperator =
112+
_finallyOperator as typeof _finallyOperator & FinallyBrand & Function;
113+
export const catchOperator = _catchOperator as typeof _catchOperator & CatchBrand & Function;
114+
export const doOperator = _doOperator as typeof _doOperator & DoBrand & Function;
115+
export const map = mapOperator as typeof mapOperator & MapBrand & Function;
116+
export const filter = filterOperator as typeof filterOperator & FilterBrand & Function;
117+
export const share = shareOperator as typeof shareOperator & ShareBrand & Function;
118+
export const first = firstOperator as typeof firstOperator & FirstBrand & Function;
119+
export const switchMap = switchMapOperator as typeof switchMapOperator & SwitchMapBrand & Function;
120+
export const startWith = startWithOperator as typeof startWithOperator & StartWithBrand & Function;
121+
export const debounceTime =
122+
debounceTimeOperator as typeof debounceTimeOperator & DebounceTimeBrand & Function;
123+
export const auditTime = auditTimeOperator as typeof auditTimeOperator & AuditTimeBrand & Function;
124+
export const takeUntil = takeUntilOperator as typeof takeUntilOperator & TakeUntilBrand & Function;

0 commit comments

Comments
 (0)