From 22843a9649b2ac56281876e7852f2f09159293ba Mon Sep 17 00:00:00 2001 From: Ryan Sundberg Date: Tue, 15 Mar 2022 00:17:56 -0700 Subject: [PATCH] Use `export type` for re-exporting type definitions Fixes compilation under typescript with `isolatedModules: true` See https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/#type-only-imports-exports --- spec/ajax/index-spec.ts | 2 +- src/ajax/index.ts | 2 +- src/index.ts | 28 ++++++++++++++++++---------- src/operators/index.ts | 21 ++++++++++++++------- src/testing/index.ts | 3 ++- src/webSocket/index.ts | 3 ++- 6 files changed, 38 insertions(+), 21 deletions(-) diff --git a/spec/ajax/index-spec.ts b/spec/ajax/index-spec.ts index 0bb1b590d9..9bc6190138 100644 --- a/spec/ajax/index-spec.ts +++ b/spec/ajax/index-spec.ts @@ -7,10 +7,10 @@ describe('index', () => { }); it('should export Ajax data classes', () => { - expect(index.AjaxResponse).to.exist; expect(index.AjaxError).to.exist; expect(index.AjaxTimeoutError).to.exist; // Interfaces can be checked by creating a variable of that type let ajaxRequest: index.AjaxRequest; + let ajaxResponse: index.AjaxResponse; }); }); diff --git a/src/ajax/index.ts b/src/ajax/index.ts index f30f026bc9..3e07b7bea0 100644 --- a/src/ajax/index.ts +++ b/src/ajax/index.ts @@ -1,4 +1,4 @@ export { ajax } from '../internal/ajax/ajax'; export { AjaxError, AjaxTimeoutError } from '../internal/ajax/errors'; export { AjaxResponse } from '../internal/ajax/AjaxResponse'; -export { AjaxRequest, AjaxConfig, AjaxDirection } from '../internal/ajax/types'; +export type { AjaxRequest, AjaxConfig, AjaxDirection } from '../internal/ajax/types'; diff --git a/src/index.ts b/src/index.ts index 759b3103af..64183f8fcf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,8 +15,8 @@ /* Observable */ export { Observable } from './internal/Observable'; export { ConnectableObservable } from './internal/observable/ConnectableObservable'; -export { GroupedObservable } from './internal/operators/groupBy'; -export { Operator } from './internal/Operator'; +export type { GroupedObservable } from './internal/operators/groupBy'; +export type { Operator } from './internal/Operator'; export { observable } from './internal/symbol/observable'; export { animationFrames } from './internal/observable/dom/animationFrames'; @@ -97,7 +97,8 @@ export { NEVER } from './internal/observable/never'; export * from './internal/types'; /* Config */ -export { config, GlobalConfig } from './internal/config'; +export { config } from './internal/config'; +export type { GlobalConfig } from './internal/config'; /* Operators */ export { audit } from './internal/operators/audit'; @@ -115,7 +116,8 @@ export { concatAll } from './internal/operators/concatAll'; export { concatMap } from './internal/operators/concatMap'; export { concatMapTo } from './internal/operators/concatMapTo'; export { concatWith } from './internal/operators/concatWith'; -export { connect, ConnectConfig } from './internal/operators/connect'; +export { connect } from './internal/operators/connect'; +export type { ConnectConfig } from './internal/operators/connect'; export { count } from './internal/operators/count'; export { debounce } from './internal/operators/debounce'; export { debounceTime } from './internal/operators/debounceTime'; @@ -138,7 +140,8 @@ export { finalize } from './internal/operators/finalize'; export { find } from './internal/operators/find'; export { findIndex } from './internal/operators/findIndex'; export { first } from './internal/operators/first'; -export { groupBy, BasicGroupByOptions, GroupByOptionsWithElement } from './internal/operators/groupBy'; +export { groupBy } from './internal/operators/groupBy'; +export type { BasicGroupByOptions, GroupByOptionsWithElement } from './internal/operators/groupBy'; export { ignoreElements } from './internal/operators/ignoreElements'; export { isEmpty } from './internal/operators/isEmpty'; export { last } from './internal/operators/last'; @@ -165,15 +168,18 @@ export { raceWith } from './internal/operators/raceWith'; export { reduce } from './internal/operators/reduce'; export { repeat } from './internal/operators/repeat'; export { repeatWhen } from './internal/operators/repeatWhen'; -export { retry, RetryConfig } from './internal/operators/retry'; +export { retry } from './internal/operators/retry'; +export type { RetryConfig } from './internal/operators/retry'; export { retryWhen } from './internal/operators/retryWhen'; export { refCount } from './internal/operators/refCount'; export { sample } from './internal/operators/sample'; export { sampleTime } from './internal/operators/sampleTime'; export { scan } from './internal/operators/scan'; export { sequenceEqual } from './internal/operators/sequenceEqual'; -export { share, ShareConfig } from './internal/operators/share'; -export { shareReplay, ShareReplayConfig } from './internal/operators/shareReplay'; +export { share } from './internal/operators/share'; +export type { ShareConfig } from './internal/operators/share'; +export { shareReplay } from './internal/operators/shareReplay'; +export type { ShareReplayConfig } from './internal/operators/shareReplay'; export { single } from './internal/operators/single'; export { skip } from './internal/operators/skip'; export { skipLast } from './internal/operators/skipLast'; @@ -190,11 +196,13 @@ export { takeLast } from './internal/operators/takeLast'; export { takeUntil } from './internal/operators/takeUntil'; export { takeWhile } from './internal/operators/takeWhile'; export { tap } from './internal/operators/tap'; -export { throttle, ThrottleConfig } from './internal/operators/throttle'; +export { throttle } from './internal/operators/throttle'; +export type { ThrottleConfig } from './internal/operators/throttle'; export { throttleTime } from './internal/operators/throttleTime'; export { throwIfEmpty } from './internal/operators/throwIfEmpty'; export { timeInterval } from './internal/operators/timeInterval'; -export { timeout, TimeoutConfig, TimeoutInfo } from './internal/operators/timeout'; +export { timeout } from './internal/operators/timeout'; +export type { TimeoutConfig, TimeoutInfo } from './internal/operators/timeout'; export { timeoutWith } from './internal/operators/timeoutWith'; export { timestamp } from './internal/operators/timestamp'; export { toArray } from './internal/operators/toArray'; diff --git a/src/operators/index.ts b/src/operators/index.ts index 9272c89780..b7da7cb879 100644 --- a/src/operators/index.ts +++ b/src/operators/index.ts @@ -16,7 +16,8 @@ export { concatAll } from '../internal/operators/concatAll'; export { concatMap } from '../internal/operators/concatMap'; export { concatMapTo } from '../internal/operators/concatMapTo'; export { concatWith } from '../internal/operators/concatWith'; -export { connect, ConnectConfig } from '../internal/operators/connect'; +export { connect } from '../internal/operators/connect'; +export type { ConnectConfig } from '../internal/operators/connect'; export { count } from '../internal/operators/count'; export { debounce } from '../internal/operators/debounce'; export { debounceTime } from '../internal/operators/debounceTime'; @@ -39,7 +40,8 @@ export { finalize } from '../internal/operators/finalize'; export { find } from '../internal/operators/find'; export { findIndex } from '../internal/operators/findIndex'; export { first } from '../internal/operators/first'; -export { groupBy, BasicGroupByOptions, GroupByOptionsWithElement } from '../internal/operators/groupBy'; +export { groupBy } from '../internal/operators/groupBy'; +export type { BasicGroupByOptions, GroupByOptionsWithElement } from '../internal/operators/groupBy'; export { ignoreElements } from '../internal/operators/ignoreElements'; export { isEmpty } from '../internal/operators/isEmpty'; export { last } from '../internal/operators/last'; @@ -70,15 +72,18 @@ export { raceWith } from '../internal/operators/raceWith'; export { reduce } from '../internal/operators/reduce'; export { repeat } from '../internal/operators/repeat'; export { repeatWhen } from '../internal/operators/repeatWhen'; -export { retry, RetryConfig } from '../internal/operators/retry'; +export { retry } from '../internal/operators/retry'; +export type { RetryConfig } from '../internal/operators/retry'; export { retryWhen } from '../internal/operators/retryWhen'; export { refCount } from '../internal/operators/refCount'; export { sample } from '../internal/operators/sample'; export { sampleTime } from '../internal/operators/sampleTime'; export { scan } from '../internal/operators/scan'; export { sequenceEqual } from '../internal/operators/sequenceEqual'; -export { share, ShareConfig } from '../internal/operators/share'; -export { shareReplay, ShareReplayConfig } from '../internal/operators/shareReplay'; +export { share } from '../internal/operators/share'; +export type { ShareConfig } from '../internal/operators/share'; +export { shareReplay } from '../internal/operators/shareReplay'; +export type { ShareReplayConfig } from '../internal/operators/shareReplay'; export { single } from '../internal/operators/single'; export { skip } from '../internal/operators/skip'; export { skipLast } from '../internal/operators/skipLast'; @@ -95,11 +100,13 @@ export { takeLast } from '../internal/operators/takeLast'; export { takeUntil } from '../internal/operators/takeUntil'; export { takeWhile } from '../internal/operators/takeWhile'; export { tap } from '../internal/operators/tap'; -export { throttle, ThrottleConfig } from '../internal/operators/throttle'; +export { throttle } from '../internal/operators/throttle'; +export type { ThrottleConfig } from '../internal/operators/throttle'; export { throttleTime } from '../internal/operators/throttleTime'; export { throwIfEmpty } from '../internal/operators/throwIfEmpty'; export { timeInterval } from '../internal/operators/timeInterval'; -export { timeout, TimeoutConfig, TimeoutInfo } from '../internal/operators/timeout'; +export { timeout } from '../internal/operators/timeout'; +export type { TimeoutConfig, TimeoutInfo } from '../internal/operators/timeout'; export { timeoutWith } from '../internal/operators/timeoutWith'; export { timestamp } from '../internal/operators/timestamp'; export { toArray } from '../internal/operators/toArray'; diff --git a/src/testing/index.ts b/src/testing/index.ts index d861e3513a..7908dc82af 100644 --- a/src/testing/index.ts +++ b/src/testing/index.ts @@ -1 +1,2 @@ -export { TestScheduler, RunHelpers } from '../internal/testing/TestScheduler'; +export { TestScheduler } from '../internal/testing/TestScheduler'; +export type { RunHelpers } from '../internal/testing/TestScheduler'; diff --git a/src/webSocket/index.ts b/src/webSocket/index.ts index 833d950479..6665d28dd4 100644 --- a/src/webSocket/index.ts +++ b/src/webSocket/index.ts @@ -1,2 +1,3 @@ export { webSocket as webSocket } from '../internal/observable/dom/webSocket'; -export { WebSocketSubject, WebSocketSubjectConfig } from '../internal/observable/dom/WebSocketSubject'; +export { WebSocketSubject } from '../internal/observable/dom/WebSocketSubject'; +export type { WebSocketSubjectConfig } from '../internal/observable/dom/WebSocketSubject';