Skip to content

Commit d3f152d

Browse files
authored
refactor(matrix): Use explicit type imports/exports where appropriate (microsoft#25028)
In preparation for enabling stricter eslint rules across the repo. Also removes a few unused eslint disable directives. Type-only imports offer a number of benefits and are considered a best practice. More details can be found here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html
1 parent 7b4d0ab commit d3f152d

22 files changed

+82
-87
lines changed

packages/dds/matrix/src/handlecache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
/* eslint-disable no-bitwise */
77

88
import { assert } from "@fluidframework/core-utils/internal";
9-
import { IVectorConsumer } from "@tiny-calc/nano";
9+
import type { IVectorConsumer } from "@tiny-calc/nano";
1010

11-
import { Handle, isHandleValid } from "./handletable.js";
12-
import { PermutationSegment, PermutationVector } from "./permutationvector.js";
11+
import { type Handle, isHandleValid } from "./handletable.js";
12+
import type { PermutationSegment, PermutationVector } from "./permutationvector.js";
1313
import { ensureRange } from "./range.js";
1414

1515
/**

packages/dds/matrix/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* Licensed under the MIT License.
44
*/
55

6-
export { ISharedMatrixEvents, ISharedMatrix } from "./matrix.js";
7-
export { MatrixItem } from "./ops.js";
6+
export type { ISharedMatrixEvents, ISharedMatrix } from "./matrix.js";
7+
export type { MatrixItem } from "./ops.js";
88
export { SharedMatrixFactory, SharedMatrix } from "./runtime.js";
99

1010
// TODO: We temporarily duplicate these contracts from 'framework/undo-redo' to unblock development
1111
// of SharedMatrix undo while we decide on the correct layering for undo.
12-
export { IUndoConsumer, IRevertible } from "./types.js";
12+
export type { IUndoConsumer, IRevertible } from "./types.js";

packages/dds/matrix/src/matrix.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,41 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import {
6+
import type {
77
IEvent,
88
IEventThisPlaceHolder,
9-
type IEventProvider,
9+
IEventProvider,
1010
} from "@fluidframework/core-interfaces";
1111
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
12-
import {
12+
import type {
1313
IChannelAttributes,
1414
IFluidDataStoreRuntime,
15-
type IChannel,
15+
IChannel,
1616
IChannelStorageService,
1717
} from "@fluidframework/datastore-definitions/internal";
18-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
18+
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
1919
import {
20-
Client,
21-
IJSONSegment,
22-
IMergeTreeOp,
20+
type Client,
21+
type IJSONSegment,
22+
type IMergeTreeOp,
2323
type ISegmentInternal,
2424
type LocalReferencePosition,
2525
MergeTreeDeltaType,
2626
ReferenceType,
2727
segmentIsRemoved,
2828
} from "@fluidframework/merge-tree/internal";
29-
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
29+
import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
3030
import {
3131
ObjectStoragePartition,
3232
SummaryTreeBuilder,
3333
} from "@fluidframework/runtime-utils/internal";
3434
import {
35-
IFluidSerializer,
36-
ISharedObjectEvents,
35+
type IFluidSerializer,
36+
type ISharedObjectEvents,
3737
SharedObject,
3838
} from "@fluidframework/shared-object-base/internal";
3939
import { UsageError } from "@fluidframework/telemetry-utils/internal";
40-
import {
40+
import type {
4141
IMatrixConsumer,
4242
IMatrixProducer,
4343
IMatrixReader,
@@ -46,20 +46,20 @@ import {
4646
import Deque from "double-ended-queue";
4747

4848
import type { HandleCache } from "./handlecache.js";
49-
import { Handle, isHandleValid } from "./handletable.js";
49+
import { type Handle, isHandleValid } from "./handletable.js";
5050
import {
51-
ISetOp,
52-
MatrixItem,
51+
type ISetOp,
52+
type MatrixItem,
5353
MatrixOp,
54-
MatrixSetOrVectorOp,
54+
type MatrixSetOrVectorOp,
5555
SnapshotPath,
56-
VectorOp,
56+
type VectorOp,
5757
} from "./ops.js";
5858
import { PermutationVector, reinsertSegmentIntoVector } from "./permutationvector.js";
5959
import { ensureRange } from "./range.js";
6060
import { deserializeBlob } from "./serialization.js";
6161
import { SparseArray2D, type RecurArray } from "./sparsearray2d.js";
62-
import { IUndoConsumer } from "./types.js";
62+
import type { IUndoConsumer } from "./types.js";
6363
import { MatrixUndoProvider } from "./undoprovider.js";
6464

6565
interface ISetOpMetadata {

packages/dds/matrix/src/ops.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* Use caustion when making changes and consider backward and forward compatibility of your changes!
99
*/
1010

11-
import { Serializable } from "@fluidframework/datastore-definitions/internal";
12-
import { IMergeTreeOp } from "@fluidframework/merge-tree/internal";
11+
import type { Serializable } from "@fluidframework/datastore-definitions/internal";
12+
import type { IMergeTreeOp } from "@fluidframework/merge-tree/internal";
1313

1414
export enum MatrixOp {
1515
spliceCols,

packages/dds/matrix/src/permutationvector.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,39 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import { IFluidHandle, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
6+
import type { IFluidHandle, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
77
import { assert } from "@fluidframework/core-utils/internal";
8-
import {
8+
import type {
99
IFluidDataStoreRuntime,
1010
IChannelStorageService,
1111
} from "@fluidframework/datastore-definitions/internal";
12-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
12+
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
1313
import {
1414
BaseSegment,
1515
Client,
16-
IJSONSegment,
17-
IMergeTreeDeltaCallbackArgs,
18-
IMergeTreeDeltaOpArgs,
19-
IMergeTreeMaintenanceCallbackArgs,
20-
ISegment,
16+
type IJSONSegment,
17+
type IMergeTreeDeltaCallbackArgs,
18+
type IMergeTreeDeltaOpArgs,
19+
type IMergeTreeMaintenanceCallbackArgs,
20+
type ISegment,
2121
MergeTreeDeltaType,
2222
MergeTreeMaintenanceType,
2323
segmentIsRemoved,
2424
type IMergeTreeInsertMsg,
2525
type IMergeTreeRemoveMsg,
2626
} from "@fluidframework/merge-tree/internal";
27-
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
27+
import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
2828
import {
2929
ObjectStoragePartition,
3030
SummaryTreeBuilder,
3131
} from "@fluidframework/runtime-utils/internal";
32-
import { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
32+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
3333
import { createChildLogger } from "@fluidframework/telemetry-utils/internal";
3434

3535
import { HandleCache } from "./handlecache.js";
3636
import { Handle, HandleTable, isHandleValid } from "./handletable.js";
3737
import { deserializeBlob } from "./serialization.js";
38-
import { VectorUndoProvider } from "./undoprovider.js";
38+
import type { VectorUndoProvider } from "./undoprovider.js";
3939

4040
const enum SnapshotPath {
4141
segments = "segments",
@@ -125,7 +125,6 @@ export class PermutationSegment extends BaseSegment {
125125
}
126126
}
127127

128-
// eslint-disable-next-line import/no-deprecated
129128
export class PermutationVector extends Client {
130129
private handleTable = new HandleTable<never>(); // Tracks available storage handles for rows.
131130
public readonly handleCache = new HandleCache(this);

packages/dds/matrix/src/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import {
6+
import type {
77
IChannel,
88
IChannelAttributes,
99
IChannelFactory,

packages/dds/matrix/src/serialization.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
*/
55

66
import { bufferToString } from "@fluid-internal/client-utils";
7-
import { IFluidHandle } from "@fluidframework/core-interfaces";
8-
import {
7+
import type { IFluidHandle } from "@fluidframework/core-interfaces";
8+
import type {
99
IChannelStorageService,
1010
Serializable,
1111
} from "@fluidframework/datastore-definitions/internal";
1212
import { BlobTreeEntry } from "@fluidframework/driver-utils/internal";
13-
import { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
13+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
1414

1515
export const serializeBlob = <T>(
1616
handle: IFluidHandle,
@@ -28,6 +28,5 @@ export async function deserializeBlob(
2828
): Promise<any> {
2929
const blob = await storage.readBlob(path);
3030
const utf8 = bufferToString(blob, "utf8");
31-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
3231
return serializer.parse(utf8);
3332
}

packages/dds/matrix/src/sparsearray2d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/* eslint-disable no-bitwise */
77

8-
import { IMatrixReader, IMatrixWriter, type IMatrixProducer } from "@tiny-calc/nano";
8+
import type { IMatrixReader, IMatrixWriter, IMatrixProducer } from "@tiny-calc/nano";
99

1010
// Build a lookup table that maps a uint8 to the corresponding uint16 where 0s
1111
// are interleaved between the original bits. (e.g., 1111... -> 01010101...).

packages/dds/matrix/src/test/dirname.cts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@
1010
// - Export '__dirname' from a .cjs file in the same directory.
1111
//
1212
// Note that *.cjs files are always CommonJS, but can be imported from ESM.
13-
// Disabled inline until the next version of the config is published.
14-
// eslint-disable-next-line unicorn/prefer-module
1513
export const _dirname = __dirname;

packages/dds/matrix/src/test/fuzz.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55

66
import { strict as assert } from "node:assert";
77

8+
import type { AsyncGenerator, Generator } from "@fluid-private/stochastic-test-utils";
89
import {
9-
AsyncGenerator,
10-
Generator,
1110
combineReducers,
1211
createWeightedGenerator,
1312
takeAsync,
1413
} from "@fluid-private/stochastic-test-utils";
15-
import { DDSFuzzTestState, type DDSFuzzModel } from "@fluid-private/test-dds-utils";
14+
import type { DDSFuzzTestState, DDSFuzzModel } from "@fluid-private/test-dds-utils";
1615
import type { IFluidHandle } from "@fluidframework/core-interfaces";
1716
import type { Serializable } from "@fluidframework/datastore-definitions/internal";
1817
import { isFluidHandle, toFluidHandleInternal } from "@fluidframework/runtime-utils/internal";
1918

20-
import { MatrixItem } from "../ops.js";
21-
import { SharedMatrixFactory, SharedMatrix } from "../runtime.js";
19+
import type { MatrixItem } from "../ops.js";
20+
import { SharedMatrix, type SharedMatrixFactory } from "../runtime.js";
2221

2322
/**
2423
* Supported cell values used within the fuzz model.

0 commit comments

Comments
 (0)