Skip to content

Commit

Permalink
Partial revert "Prefix trivial issues when enabling no-unchecked-reco…
Browse files Browse the repository at this point in the history
…rd-access for client packages (microsoft#23432)"

This reverts commit 88caebd where `T | undefined` was used to address linter defect. TypeScript will narrow without `undefined` without noUncheckedIndexAccess enabled. So remove ineffective pattern.

The only files that retained changes are:
  packages/dds/merge-tree/src/test/beastTest.spec.ts
  packages/drivers/odsp-driver/src/WriteBufferUtils.ts
  packages/runtime/id-compressor/src/test/idCompressor.spec.ts
  packages/tools/fetch-tool/src/fluidFetchSnapshot.ts
  • Loading branch information
jason-ha committed Jan 7, 2025
1 parent 64351b7 commit a5ec7a0
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 27 deletions.
4 changes: 2 additions & 2 deletions packages/drivers/odsp-driver/src/WriteBufferUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ function serializeNodeCore(
for (const child of nodeCore.nodes) {
if (child instanceof NodeCore) {
// For a tree node start and end with set/list start and end marker codes.
const startCode: MarkerCodesStart | undefined = MarkerCodesStart[child.type];
const endCode: MarkerCodesEnd | undefined = MarkerCodesEnd[child.type];
const startCode = MarkerCodesStart[child.type];
const endCode = MarkerCodesEnd[child.type];
assert(startCode !== undefined, 0x285 /* "Start code should not undefined" */);
assert(endCode !== undefined, 0x286 /* "End code should not undefined" */);
buffer.write(startCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ export abstract class OdspDocumentStorageServiceBase implements IDocumentStorage
protected combineProtocolAndAppSnapshotTree(snapshotTree: ISnapshotTree): ISnapshotTree {
// When we upload the container snapshot, we upload appTree in ".app" and protocol tree in ".protocol"
// So when we request the snapshot we get ".app" as tree and not as commit node as in the case just above.
const hierarchicalAppTree: ISnapshotTree | undefined = snapshotTree.trees[".app"];
const hierarchicalProtocolTree: ISnapshotTree | undefined =
snapshotTree.trees[".protocol"];
const hierarchicalAppTree = snapshotTree.trees[".app"];
const hierarchicalProtocolTree = snapshotTree.trees[".protocol"];
const summarySnapshotTree: ISnapshotTree = {
blobs: {
...hierarchicalAppTree.blobs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { strict as assert } from "node:assert";

import { bufferToString, fromBase64ToUtf8 } from "@fluid-internal/client-utils";
import { ISummaryTree, SummaryType } from "@fluidframework/driver-definitions";
import {
ISnapshot,
IDocumentAttributes,
type ISnapshotTree,
} from "@fluidframework/driver-definitions/internal";
import { ISnapshot, IDocumentAttributes } from "@fluidframework/driver-definitions/internal";
import {
IFileEntry,
IOdspResolvedUrl,
Expand Down Expand Up @@ -143,18 +139,18 @@ describe("Create New Utils Tests", () => {
);
assert.strictEqual(snapshot.blobContents.size, 2, "2 blobs should be there");

const appTree: ISnapshotTree | undefined = snapshotTree.trees[".app"];
const protocolTree: ISnapshotTree | undefined = snapshotTree.trees[".protocol"];
const appTree = snapshotTree.trees[".app"];
const protocolTree = snapshotTree.trees[".protocol"];
assert(appTree !== undefined, "App tree should be there");
assert(protocolTree !== undefined, "Protocol tree should be there");

const appTreeBlobId: string | undefined = appTree.blobs.attributes;
const appTreeBlobId = appTree.blobs.attributes;
const appTreeBlobValBuffer = snapshot.blobContents.get(appTreeBlobId);
assert(appTreeBlobValBuffer !== undefined, "app blob value should exist");
const appTreeBlobVal = bufferToString(appTreeBlobValBuffer, "utf8");
assert(appTreeBlobVal === blobContent, "Blob content should match");

const docAttributesBlobId: string | undefined = protocolTree.blobs.attributes;
const docAttributesBlobId = protocolTree.blobs.attributes;
const docAttributesBuffer = snapshot.blobContents.get(docAttributesBlobId);
assert(docAttributesBuffer !== undefined, "protocol attributes blob value should exist");
const docAttributesBlobValue = bufferToString(docAttributesBuffer, "utf8");
Expand Down
4 changes: 2 additions & 2 deletions packages/drivers/replay-driver/src/storageImplementations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ export class FileSnapshotReader
throw new Error(`Unknown version id: ${versionRequested}`);
}

let snapshotTree: ISnapshotTree | undefined = this.trees[versionRequested.id];
let snapshotTree = this.trees[versionRequested.id];
if (snapshotTree === undefined) {
const tree: ITree | undefined = this.commits[versionRequested.id];
const tree = this.commits[versionRequested.id];
if (tree === undefined) {
throw new Error(`Can't find version ${versionRequested.id}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
type FetchSource,
type IDocumentAttributes,
SummaryType,
type SummaryObject,
} from "@fluidframework/driver-definitions/internal";
import {
ISummaryTreeWithStats,
Expand Down Expand Up @@ -2094,7 +2093,7 @@ describe("Runtime", () => {
false,
);
const { summary } = await containerRuntime.summarize({ fullTree: true });
const blob: SummaryObject | undefined = summary.tree[recentBatchInfoBlobName];
const blob = summary.tree[recentBatchInfoBlobName];
assert(blob.type === SummaryType.Blob, "Expected blob");
assert.equal(blob.content, '[[123,"batchId1"]]', "Expected single batchId mapping");

Expand Down
8 changes: 4 additions & 4 deletions packages/runtime/runtime-utils/src/test/summaryUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ describe("Summary Utils", () => {
const blobContent = "testBlobContent";
summaryTreeBuilder.addBlob("testBlob", blobContent);
const summaryTree = summaryTreeBuilder.summary;
const blob: SummaryObject | undefined = summaryTree.tree.testBlob;
const blob = summaryTree.tree.testBlob;
assert.strictEqual(blob.type, SummaryType.Blob);
assert.strictEqual(blob.content, blobContent);
});
Expand All @@ -432,7 +432,7 @@ describe("Summary Utils", () => {
const handle = "testHandle";
summaryTreeBuilder.addHandle("testHandleKey", SummaryType.Tree, handle);
const summaryTree = summaryTreeBuilder.summary;
const handleObject: SummaryObject | undefined = summaryTree.tree.testHandleKey;
const handleObject = summaryTree.tree.testHandleKey;
assert.strictEqual(handleObject.type, SummaryType.Handle);
assert.strictEqual(handleObject.handleType, SummaryType.Tree);
assert.strictEqual(handleObject.handle, handle);
Expand All @@ -453,7 +453,7 @@ describe("Summary Utils", () => {
const attachmentId = "testAttachmentId";
summaryTreeBuilder.addAttachment(attachmentId);
const summaryTree = summaryTreeBuilder.summary;
const attachment: SummaryObject | undefined = summaryTree.tree["0"];
const attachment = summaryTree.tree["0"];
assert.strictEqual(attachment.type, SummaryType.Attachment);
assert.strictEqual(attachment.id, attachmentId);
});
Expand All @@ -473,7 +473,7 @@ describe("Summary Utils", () => {
};
summaryTreeBuilder.addWithStats("testKey", summarizeResult);
const summaryTree = summaryTreeBuilder.summary;
const subTree: SummaryObject | undefined = summaryTree.tree.testKey;
const subTree = summaryTree.tree.testKey;
assert.strictEqual(subTree.type, SummaryType.Tree);
const stats = summaryTreeBuilder.stats;
assert.strictEqual(stats.blobNodeCount, 1);
Expand Down
3 changes: 1 addition & 2 deletions packages/test/test-drivers/src/routerliciousTestDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ function getLegacyConfigFromEnv() {
}

function getEndpointConfigFromEnv(r11sEndpointName: RouterliciousEndpoint) {
const configStr: string | undefined =
process.env[`fluid__test__driver__${r11sEndpointName}`];
const configStr = process.env[`fluid__test__driver__${r11sEndpointName}`];
if (r11sEndpointName === "docker") {
const dockerDriverPolicies =
configStr === undefined ? configStr : JSON.parse(configStr).driverPolicies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ export class DataVisualizerGraph
this.visualizers[sharedObject.attributes.type] ?? visualizeUnknownSharedObject;

// Create visualizer node for the shared object
const editorFunction: EditSharedObject | undefined =
this.editors[sharedObject.attributes.type];
const editorFunction = this.editors[sharedObject.attributes.type];

const visualizerNode = new VisualizerNode(
sharedObject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const mergeDataSets = (dataSets: GraphDataSet[]): DataPoint[] => {
for (const dataSet of dataSets) {
const { yAxisDataKey, xAxisDataKey, uuid } = dataSet.schema;
for (const dataPoint of dataSet.data) {
const xAxisDataPoint: string | number | undefined = dataPoint[xAxisDataKey];
const xAxisDataPoint = dataPoint[xAxisDataKey];
xAxisDataPointToYAxisDataPointMap[xAxisDataPoint] = {
...xAxisDataPointToYAxisDataPointMap[xAxisDataPoint],
[uuid]: dataPoint[yAxisDataKey],
Expand Down

0 comments on commit a5ec7a0

Please sign in to comment.