diff --git a/src/actions/profile-view.ts b/src/actions/profile-view.ts index 9ca988d8cc..2e8cb89717 100644 --- a/src/actions/profile-view.ts +++ b/src/actions/profile-view.ts @@ -1271,9 +1271,10 @@ function _findOtherVisibleThread( const localTracks = getLocalTracks(getState(), globalTrack.pid); const localTrackOrder = getLocalTrackOrder(getState(), globalTrack.pid); const hiddenLocalTracks = getHiddenLocalTracks(getState(), globalTrack.pid); - const localTrackIndexesToIgnore = localTrackIndexesToIgnoreByPid - ? (localTrackIndexesToIgnoreByPid.get(globalTrack.pid) ?? new Set()) - : new Set(); + const localTrackIndexesToIgnore: Set = + localTrackIndexesToIgnoreByPid + ? (localTrackIndexesToIgnoreByPid.get(globalTrack.pid) ?? new Set()) + : new Set(); for (const trackIndex of localTrackOrder) { const track = localTracks[trackIndex]; diff --git a/src/app-logic/url-handling.ts b/src/app-logic/url-handling.ts index 60267bbc77..c3e1e9e3fa 100644 --- a/src/app-logic/url-handling.ts +++ b/src/app-logic/url-handling.ts @@ -635,7 +635,7 @@ function convertHiddenLocalTracksByPidFromString( return new Map(); } - const hiddenLocalTracksByPid = new Map(); + const hiddenLocalTracksByPid: Map> = new Map(); for (const stringPart of rawText.split('~')) { if (!stringPart.includes('-')) { @@ -679,7 +679,7 @@ function convertLocalTrackOrderByPidFromString( return new Map(); } - const localTrackOrderByPid = new Map(); + const localTrackOrderByPid: Map = new Map(); for (const stringPart of rawText.split('~')) { if (!stringPart.includes('-')) { @@ -1018,12 +1018,10 @@ const _upgraders: { .join('~'); } if (query.thread) { - const selectedThreads = new Set( + const selectedThreads: Set = new Set( query.thread.split(',').map((n: string) => +n) ); - query.thread = encodeUintSetForUrlComponent( - selectedThreads as Set - ); + query.thread = encodeUintSetForUrlComponent(selectedThreads); } // In this version, uintarray-encoding started supporting a range syntax: diff --git a/src/components/shared/AssemblyView-codemirror.tsx b/src/components/shared/AssemblyView-codemirror.tsx index d1eba6e92e..12385ae8b9 100644 --- a/src/components/shared/AssemblyView-codemirror.tsx +++ b/src/components/shared/AssemblyView-codemirror.tsx @@ -149,7 +149,7 @@ function addressTimingsToLineTimings( addressTimings: AddressTimings, map: AddressToLineMap ): LineTimings { - const totalLineHits = new Map(); + const totalLineHits: Map = new Map(); for (const [address, hitCount] of addressTimings.totalAddressHits) { const line = map.addressToLine(address); if (line !== null) { @@ -158,7 +158,7 @@ function addressTimingsToLineTimings( } } - const selfLineHits = new Map(); + const selfLineHits: Map = new Map(); for (const [address, hitCount] of addressTimings.selfAddressHits) { const line = map.addressToLine(address); if (line !== null) { diff --git a/src/components/tooltip/GCMarker.tsx b/src/components/tooltip/GCMarker.tsx index b9dd40603b..72576194f3 100644 --- a/src/components/tooltip/GCMarker.tsx +++ b/src/components/tooltip/GCMarker.tsx @@ -466,7 +466,7 @@ function _filterInterestingPhaseTimes( /* * Build the tree. */ - const tree = new Map(); + const tree: Map = new Map(); for (const phase of phaseTimes) { const components = phase.name.split('.'); _treeInsert(tree, components, phase); diff --git a/src/profile-logic/call-node-info.ts b/src/profile-logic/call-node-info.ts index 6c0a90e7db..c6406916f4 100644 --- a/src/profile-logic/call-node-info.ts +++ b/src/profile-logic/call-node-info.ts @@ -1161,7 +1161,7 @@ export class CallNodeInfoInverted implements CallNodeInfo { // Pass 1: Count the deep nodes per func, and build up a list of funcs. // We will need to create a child for each deep node func, and each child will // need to know how many deep nodes it has. - const deepNodeCountPerFunc = new Map(); + const deepNodeCountPerFunc: Map = new Map(); const callNodeTable = this._callNodeTable; for (let i = 0; i < parentDeepNodeCount; i++) { const selfNode = parentSelfNodes[i]; @@ -1212,7 +1212,7 @@ export class CallNodeInfoInverted implements CallNodeInfo { // partitions; one partition per child, in the right order. const startIndexPerChild = new Uint32Array(childCount); const deepNodeCountPerChild = new Uint32Array(childCount); - const funcToChildIndex = new Map(); + const funcToChildIndex: Map = new Map(); let nextChildStartIndex = 0; for (let childIndex = 0; childIndex < childCount; childIndex++) { diff --git a/src/profile-logic/import/art-trace.ts b/src/profile-logic/import/art-trace.ts index 4e3d805c6d..b2d47f0679 100644 --- a/src/profile-logic/import/art-trace.ts +++ b/src/profile-logic/import/art-trace.ts @@ -3,6 +3,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // Parses the ART trace format and converts it to the Gecko profile format. +import type { + IndexIntoFrameTable, + IndexIntoStackTable, +} from 'firefox-profiler/types'; + // These profiles are obtained from Android in two ways: // - Programmatically, from the Debug API: https://developer.android.com/studio/profile/cpu-profiler#debug-api // - Or via the profiler UI in Android Studio. @@ -562,7 +567,7 @@ function procureSamplingInterval(trace: ArtTrace) { // Gather up to 500 time deltas between method actions on a thread. const deltas: number[] = []; - const previousTimestampByThread = new Map(); + const previousTimestampByThread: Map = new Map(); const numberOfActionsToConsider = Math.min(500, methodActions.length); for (let i = 0; i < numberOfActionsToConsider; i++) { const { tid, globalTime } = methodActions[i]; @@ -617,7 +622,7 @@ export function getSpecialCategory( return s.substring(0, firstPeriodPos); } - const significantSegmentCounter = new Map(); + const significantSegmentCounter: Map = new Map(); for (let i = 0; i < methods.length; i++) { const significantSegment = getSignificantNamespaceSegment( methods[i].className @@ -787,8 +792,8 @@ class ThreadBuilder { _currentStack: number | null = null; _nextSampleTimestamp = 0; - _stackMap = new Map(); - _frameMap = new Map(); + _stackMap: Map = new Map(); + _frameMap: Map = new Map(); _registerTime = 0; _name; _pid; @@ -939,7 +944,7 @@ export function convertArtTraceProfile( const { summaryDetails, threads, methods, methodActions } = trace; const categoryInfo = new CategoryInfo(methods); const methodMap = new Map(methods.map((m) => [m.methodId, m])); - const threadBuilderMap = new Map(); + const threadBuilderMap: Map = new Map(); if (methodActions.length > 0) { for (let i = 0; i < methodActions.length; i++) { diff --git a/src/profile-logic/import/chrome.ts b/src/profile-logic/import/chrome.ts index 63d2f6c2c6..6aa61ae8ce 100644 --- a/src/profile-logic/import/chrome.ts +++ b/src/profile-logic/import/chrome.ts @@ -396,10 +396,11 @@ function getThreadInfo( profile.threads.push(thread); - const nodeIdToStackId = new Map(); + const nodeIdToStackId: Map = + new Map(); nodeIdToStackId.set(undefined, null); - const threadInfo = { + const threadInfo: ThreadInfo = { thread, nodeIdToStackId, funcKeyToFuncId: new Map(), @@ -518,8 +519,8 @@ async function processTracingEvents( ensureExists(profile.meta.categories) ); - const threadInfoByPidAndTid = new Map(); - const threadInfoByThread = new Map(); + const threadInfoByPidAndTid: Map = new Map(); + const threadInfoByThread: Map = new Map(); for (const profileEvent of profileEvents) { // The thread info is all of the data that makes it possible to process an // individual thread. @@ -574,7 +575,7 @@ async function processTracingEvents( } = thread; if (nodes) { - const parentMap = new Map(); + const parentMap: Map = new Map(); for (const node of nodes) { const { callFrame, id: nodeIndex } = node; let parent: number | void = undefined; diff --git a/src/profile-logic/import/linux-perf.ts b/src/profile-logic/import/linux-perf.ts index b20c6185b5..8daf8f6782 100644 --- a/src/profile-logic/import/linux-perf.ts +++ b/src/profile-logic/import/linux-perf.ts @@ -2,7 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import type { MixedObject } from 'firefox-profiler/types'; +import type { + IndexIntoFrameTable, + IndexIntoStackTable, + MixedObject, +} from 'firefox-profiler/types'; /** * The "perf script" format is the plain text format that is output by an @@ -118,7 +122,7 @@ export function convertPerfScriptProfile( }; const stringTable: string[] = []; - const stackMap = new Map(); + const stackMap: Map = new Map(); function getOrCreateStack(frame: number, prefix: number | null) { const key = prefix === null ? `${frame}` : `${frame},${prefix}`; let stack = stackMap.get(key); @@ -130,7 +134,7 @@ export function convertPerfScriptProfile( return stack; } - const frameMap = new Map(); + const frameMap: Map = new Map(); function getOrCreateFrame(frameString: string): number { let frame = frameMap.get(frameString); if (frame === undefined) { diff --git a/src/profile-logic/js-tracer.tsx b/src/profile-logic/js-tracer.tsx index 2a18d95e13..43fb52c42b 100644 --- a/src/profile-logic/js-tracer.tsx +++ b/src/profile-logic/js-tracer.tsx @@ -38,7 +38,7 @@ function getScriptLocationToFuncIndex( sources: SourceTable ): ScriptLocationToFuncIndex { const { funcTable } = thread; - const scriptLocationToFuncIndex = new Map(); + const scriptLocationToFuncIndex: ScriptLocationToFuncIndex = new Map(); for (let funcIndex = 0; funcIndex < funcTable.length; funcIndex++) { if (!funcTable.isJS[funcIndex]) { continue; diff --git a/src/profile-logic/marker-data.ts b/src/profile-logic/marker-data.ts index f8abcce05c..fba90cc7d6 100644 --- a/src/profile-logic/marker-data.ts +++ b/src/profile-logic/marker-data.ts @@ -484,7 +484,7 @@ export function correlateIPCMarkers( recvThreadName: formatThreadName(recvTid), }; - const addedThreadIds = new Set(); + const addedThreadIds: Set = new Set(); if (startEndpointMarker) { addedThreadIds.add(startEndpointMarker.tid); correlations.set( @@ -1331,7 +1331,7 @@ export function groupScreenshotsById( getMarker: (markerIndex: MarkerIndex) => Marker, markerIndexes: MarkerIndex[] ): Map { - const idToScreenshotMarkers = new Map(); + const idToScreenshotMarkers: Map = new Map(); for (const markerIndex of markerIndexes) { const marker = getMarker(markerIndex); const { data } = marker; diff --git a/src/profile-logic/marker-schema.tsx b/src/profile-logic/marker-schema.tsx index ec392732b2..fd56e9ba34 100644 --- a/src/profile-logic/marker-schema.tsx +++ b/src/profile-logic/marker-schema.tsx @@ -674,7 +674,7 @@ export function markerPayloadMatchesSearch( export function computeStringIndexMarkerFieldsByDataType( markerSchemas: MarkerSchema[] ): Map { - const stringIndexMarkerFieldsByDataType = new Map(); + const stringIndexMarkerFieldsByDataType: Map = new Map(); // 'CompositorScreenshot' markers currently don't have a schema (#5303), // hardcode the url field (which is a string index) until they do. diff --git a/src/profile-logic/merge-compare.ts b/src/profile-logic/merge-compare.ts index be1bdaabdd..8f3337a9fd 100644 --- a/src/profile-logic/merge-compare.ts +++ b/src/profile-logic/merge-compare.ts @@ -444,7 +444,7 @@ function mergeCategories(categoriesPerProfile: Array): { const newCategoryIndexByName: Map = new Map(); const translationMaps = categoriesPerProfile.map((categories) => { - const translationMap = new Map(); + const translationMap: TranslationMapForCategories = new Map(); if (!categories) { // Profiles that are imported may not have categories. Ignore it when attempting @@ -482,7 +482,7 @@ function mergeStringArrays(stringArraysPerProfile: Array): { const newStringTable = StringTable.withBackingArray(newStringArray); const translationMaps = stringArraysPerProfile.map((stringArray) => { - const translationMap = new Map(); + const translationMap: TranslationMapForStrings = new Map(); for (let i = 0; i < stringArray.length; i++) { translationMap.set(i, newStringTable.indexForString(stringArray[i])); } @@ -503,7 +503,7 @@ function mergeSources( const mapOfInsertedSources: Map = new Map(); const translationMaps = sourcesPerProfile.map((sources, profileIndex) => { - const translationMap = new Map(); + const translationMap: TranslationMapForSources = new Map(); if (!sources) { return translationMap; } @@ -725,11 +725,11 @@ function mergeLibs(libsPerProfile: Lib[][]): { } { const mapOfInsertedLibs: Map = new Map(); - const translationMaps: Array> = []; + const translationMaps: Array = []; const newLibTable: Lib[] = []; for (const libs of libsPerProfile) { - const translationMap = new Map(); + const translationMap: TranslationMapForLibs = new Map(); libs.forEach((lib, i) => { const insertedLibKey = [lib.name, lib.debugName].join('#'); @@ -765,7 +765,7 @@ function combineResourceTables(threads: ReadonlyArray): { const newResourceTable = getEmptyResourceTable(); threads.forEach((thread) => { - const translationMap = new Map(); + const translationMap: TranslationMapForResources = new Map(); const { resourceTable } = thread; for (let i = 0; i < resourceTable.length; i++) { @@ -811,7 +811,7 @@ function combineNativeSymbolTables(threads: ReadonlyArray): { const newNativeSymbols = getEmptyNativeSymbolTable(); threads.forEach((thread) => { - const translationMap = new Map(); + const translationMap: TranslationMapForNativeSymbols = new Map(); const { nativeSymbols } = thread; for (let i = 0; i < nativeSymbols.length; i++) { @@ -861,7 +861,7 @@ function combineFuncTables( threads.forEach((thread, threadIndex) => { const { funcTable } = thread; - const translationMap = new Map(); + const translationMap: TranslationMapForFuncs = new Map(); const resourceTranslationMap = translationMapsForResources[threadIndex]; for (let i = 0; i < funcTable.length; i++) { @@ -931,7 +931,7 @@ function combineFrameTables( threads.forEach((thread, threadIndex) => { const { frameTable } = thread; - const translationMap = new Map(); + const translationMap: TranslationMapForFrames = new Map(); const funcTranslationMap = translationMapsForFuncs[threadIndex]; const nativeSymbolTranslationMap = translationMapsForNativeSymbols[threadIndex]; @@ -993,7 +993,7 @@ function combineStackTables( threads.forEach((thread, threadIndex) => { const { stackTable } = thread; - const translationMap = new Map(); + const translationMap: TranslationMapForStacks = new Map(); const frameTranslationMap = translationMapsForFrames[threadIndex]; for (let i = 0; i < stackTable.length; i++) { @@ -1042,7 +1042,7 @@ function combineSamplesDiffing( ThreadAndWeightMultiplier, ] ): { samples: RawSamplesTable; translationMaps: TranslationMapForSamples[] } { - const translationMaps = [new Map(), new Map()]; + const translationMaps: TranslationMapForSamples[] = [new Map(), new Map()]; const [ { thread: { samples: samples1, tid: tid1 }, @@ -1427,7 +1427,7 @@ function mergeMarkers( threads.forEach((thread, threadIndex) => { const translationMapForStacks = translationMapsForStacks[threadIndex]; - const translationMap = new Map(); + const translationMap: TranslationMapForMarkers = new Map(); const { markers } = thread; for (let markerIndex = 0; markerIndex < markers.length; markerIndex++) { diff --git a/src/profile-logic/mozilla-symbolication-api.ts b/src/profile-logic/mozilla-symbolication-api.ts index 2c8ecfc092..17fff7f637 100644 --- a/src/profile-logic/mozilla-symbolication-api.ts +++ b/src/profile-logic/mozilla-symbolication-api.ts @@ -202,7 +202,7 @@ function getV5ResultForLibRequest( ); } - const results = new Map(); + const results: Map = new Map(); for (let i = 0; i < addressInfo.length; i++) { const address = addressArray[i]; const info = addressInfo[i]; diff --git a/src/profile-logic/process-profile.ts b/src/profile-logic/process-profile.ts index 7a363ec58d..72f5d26a58 100644 --- a/src/profile-logic/process-profile.ts +++ b/src/profile-logic/process-profile.ts @@ -99,6 +99,7 @@ import type { Pid, GeckoMarkerSchema, GeckoSourceTable, + IndexIntoCategoryList, } from 'firefox-profiler/types'; import { decompress, isGzip } from 'firefox-profiler/utils/gz'; @@ -1548,7 +1549,8 @@ export function insertExternalMarkersIntoProfile( } } - const categoryMap = new Map(); + const categoryMap: Map = + new Map(); for (let i = 0; i < externalMarkers.categories.length; ++i) { const cat = externalMarkers.categories[i]; let index = geckoProfile.meta.categories.findIndex( diff --git a/src/profile-logic/profile-data.ts b/src/profile-logic/profile-data.ts index 7c9b4911ae..7b31e1361c 100644 --- a/src/profile-logic/profile-data.ts +++ b/src/profile-logic/profile-data.ts @@ -2920,7 +2920,10 @@ export function reserveFunctionsInThread( thread: Thread ): ThreadWithReservedFunctions { const funcTable = shallowCloneFuncTable(thread.funcTable); - const reservedFunctionsForResources = new Map(); + const reservedFunctionsForResources: Map< + IndexIntoResourceTable, + IndexIntoFuncTable + > = new Map(); const jsResourceTypes = [ resourceTypes.addon, resourceTypes.url, @@ -3271,7 +3274,7 @@ export function extractProfileFilterPageData( return new Map(); } - const pageDataByTabID = new Map(); + const pageDataByTabID: Map = new Map(); for (const [tabID, pages] of pagesMapByTabID) { let topMostPages = pages.filter( (page) => @@ -3643,7 +3646,7 @@ export function nudgeReturnAddresses(thread: RawThread): RawThread { // These are the top ("self") frames of stacks from sampling. // In the variable names below, ip means "instruction pointer". const oldIpFrameToNewIpFrame = new Uint32Array(frameTable.length); - const ipFrames = new Set(); + const ipFrames: Set = new Set(); for (const stack of samplingSelfStacks) { const frame = stackTable.frame[stack]; oldIpFrameToNewIpFrame[frame] = frame; @@ -3728,8 +3731,14 @@ export function nudgeReturnAddresses(thread: RawThread): RawThread { // Make a new stack table which refers to the adjusted frames. const newStackTable = getEmptyRawStackTable(); - const mapForSamplingSelfStacks = new Map(); - const mapForBacktraceSelfStacks = new Map(); + const mapForSamplingSelfStacks: Map< + null | IndexIntoStackTable, + null | IndexIntoStackTable + > = new Map(); + const mapForBacktraceSelfStacks: Map< + null | IndexIntoStackTable, + null | IndexIntoStackTable + > = new Map(); const prefixMap = new Uint32Array(stackTable.length); for (let stack = 0; stack < stackTable.length; stack++) { const frame = stackTable.frame[stack]; @@ -4043,7 +4052,7 @@ export function computeTabToThreadIndexesMap( threads: RawThread[], innerWindowIDToTabMap: Map | null ): Map> { - const tabToThreadIndexesMap = new Map(); + const tabToThreadIndexesMap: Map> = new Map(); if (!innerWindowIDToTabMap) { // There is no pages information in the profile, return an empty map. return tabToThreadIndexesMap; diff --git a/src/profile-logic/symbol-store.ts b/src/profile-logic/symbol-store.ts index abc5950c4c..622f44b644 100644 --- a/src/profile-logic/symbol-store.ts +++ b/src/profile-logic/symbol-store.ts @@ -106,7 +106,7 @@ export function readSymbolsFromSymbolTable( // the symbolTableIndex array. // Both addressArray and symbolTableAddrs are sorted in ascending order. const decoder = new TextDecoder(); - const results = new Map(); + const results: Map = new Map(); let currentSymbolIndex = undefined; let currentSymbol = ''; let currentSymbolFunctionSize = undefined; diff --git a/src/profile-logic/symbolication.ts b/src/profile-logic/symbolication.ts index e812602ec7..5b19e499f6 100644 --- a/src/profile-logic/symbolication.ts +++ b/src/profile-logic/symbolication.ts @@ -240,8 +240,8 @@ type ThreadSymbolicationInfo = Map; function makeConsensusMap( iterableOfEntryPairs: Iterable<[K, V]> ): Map { - const consensusMap = new Map(); - const divergentKeys = new Set(); + const consensusMap: Map = new Map(); + const divergentKeys: Set = new Set(); for (const [key, value] of iterableOfEntryPairs) { if (divergentKeys.has(key)) { continue; @@ -270,7 +270,7 @@ function getThreadSymbolicationInfo( ): ThreadSymbolicationInfo { const { frameTable, funcTable, nativeSymbols, resourceTable } = thread; - const map = new Map(); + const map: ThreadSymbolicationInfo = new Map(); for ( let resourceIndex = 0; resourceIndex < resourceTable.length; @@ -292,7 +292,7 @@ function getThreadSymbolicationInfo( } // Collect the set of funcs for this library in this thread. - const allFuncsForThisLib = new Set(); + const allFuncsForThisLib: Set = new Set(); for (let funcIndex = 0; funcIndex < funcTable.length; funcIndex++) { if (funcTable.resource[funcIndex] !== resourceIndex) { continue; @@ -301,7 +301,8 @@ function getThreadSymbolicationInfo( } // Collect the set of native symbols for this library in this thread. - const allNativeSymbolsForThisLib = new Set(); + const allNativeSymbolsForThisLib: Set = + new Set(); for ( let nativeSymbolIndex = 0; nativeSymbolIndex < nativeSymbols.length; @@ -343,7 +344,7 @@ function getThreadSymbolicationInfo( function buildLibSymbolicationRequestsForAllThreads( symbolicationInfo: ThreadSymbolicationInfo[] ): LibSymbolicationRequest[] { - const libKeyToAddressesMap = new Map(); + const libKeyToAddressesMap: Map> = new Map(); for (const threadSymbolicationInfo of symbolicationInfo) { for (const [libKey, { frameAddresses }] of threadSymbolicationInfo) { let addressSet = libKeyToAddressesMap.get(libKey); @@ -478,10 +479,13 @@ export function applySymbolicationSteps( shared: RawProfileSharedData, symbolicationSteps: SymbolicationStepInfo[] ): { thread: RawThread; oldFuncToNewFuncsMap: FuncToFuncsMap } { - const oldFuncToNewFuncsMap = new Map(); + const oldFuncToNewFuncsMap: FuncToFuncsMap = new Map(); const frameCount = oldThread.frameTable.length; const shouldStacksWithThisFrameBeRemoved = new Uint8Array(frameCount); - const frameIndexToInlineExpansionFrames = new Map(); + const frameIndexToInlineExpansionFrames: Map< + IndexIntoFrameTable, + IndexIntoFrameTable[] + > = new Map(); let thread = oldThread; for (const symbolicationStep of symbolicationSteps) { thread = _partiallyApplySymbolicationStep( @@ -716,7 +720,7 @@ function _partiallyApplySymbolicationStep( const availableFuncIter = availableFuncs.values(); // funcKey -> funcIndex, where funcKey = `${nameStringIndex}:${fileStringIndex}` - const funcKeyToFuncMap = new Map(); + const funcKeyToFuncMap: Map = new Map(); const availableFrameIter = inlinedFrames.values(); const oldFuncToNewFuncsEntries: Array<[IndexIntoFuncTable, string]> = []; diff --git a/src/profile-logic/tracks.ts b/src/profile-logic/tracks.ts index 44277e17b5..8a6852f12e 100644 --- a/src/profile-logic/tracks.ts +++ b/src/profile-logic/tracks.ts @@ -239,7 +239,7 @@ export function initializeLocalTrackOrderByPid( legacyThreadOrder: ThreadIndex[] | null, profile: Profile | null ): Map { - const trackOrderByPid = new Map(); + const trackOrderByPid: Map = new Map(); if (legacyThreadOrder === null) { // Go through each set of tracks, determine the sort order. @@ -310,7 +310,7 @@ export function computeLocalTracksByPid( profile: Profile, availableGlobalTracks: GlobalTrack[] ): Map { - const localTracksByPid = new Map(); + const localTracksByPid: Map = new Map(); // Create a new set of available pids, so we can filter out the local tracks // if their globalTracks are also filtered out by the tab selector. @@ -448,7 +448,7 @@ export function addEventDelayTracksForThreads( threads: RawThread[], localTracksByPid: Map ): Map { - const newLocalTracksByPid = new Map(); + const newLocalTracksByPid: Map = new Map(); for (let threadIndex = 0; threadIndex < threads.length; threadIndex++) { const thread = threads[threadIndex]; @@ -909,7 +909,7 @@ export function tryInitializeHiddenTracksFromUrl( urlHiddenGlobalTracks ); - const hiddenLocalTracksByPid = new Map(); + const hiddenLocalTracksByPid: Map> = new Map(); for (const [pid, localTrackOrder] of tracksWithOrder.localTrackOrderByPid) { const localTracks = new Set(localTrackOrder); const hiddenLocalTracks = intersectSets( @@ -987,7 +987,7 @@ function _computeHiddenTracksForVisibleThreads( }) ); - const hiddenLocalTracksByPid = new Map(); + const hiddenLocalTracksByPid: Map> = new Map(); for (const [pid, localTrackOrder] of tracksWithOrder.localTrackOrderByPid) { if (!visiblePids.has(pid)) { // Hide all local tracks. @@ -1520,7 +1520,7 @@ export function getSearchFilteredLocalTracksByPid( return null; } - const searchFilteredLocalTracksByPid = new Map(); + const searchFilteredLocalTracksByPid: Map> = new Map(); for (const [pid, tracks] of localTracksByPid) { const searchFilteredLocalTracks = new Set(); const localTrackNames = localTrackNamesByPid.get(pid); @@ -1640,7 +1640,7 @@ export function getTypeFilteredLocalTracksByPid( return null; } - const typeFilteredLocalTracksByPid = new Map(); + const typeFilteredLocalTracksByPid: Map> = new Map(); for (const [pid, tracks] of localTracksByPid) { const typeFilteredLocalTracks = new Set(); diff --git a/src/profile-logic/transforms.ts b/src/profile-logic/transforms.ts index a1f373579f..c5c1910d04 100644 --- a/src/profile-logic/transforms.ts +++ b/src/profile-logic/transforms.ts @@ -1383,7 +1383,10 @@ export function focusInvertedSubtree( return null; } - const oldStackToNewStack = new Map(); + const oldStackToNewStack: Map< + IndexIntoStackTable | null, + IndexIntoStackTable | null + > = new Map(); // A root stack's prefix will be null. Maintain that relationship from old to new // stacks by mapping from null to null. oldStackToNewStack.set(null, null); diff --git a/src/selectors/app.tsx b/src/selectors/app.tsx index 65cb1d043e..aeeb8de6ea 100644 --- a/src/selectors/app.tsx +++ b/src/selectors/app.tsx @@ -35,6 +35,7 @@ import type { ThreadsKey, ExperimentalFlags, UploadedProfileInformation, + Pid, } from 'firefox-profiler/types'; import type { TabSlug } from 'firefox-profiler/app-logic/tabs-handling'; import type { @@ -148,7 +149,7 @@ export const getTimelineHeight: Selector = createSelector( } // Figure out which PIDs are hidden. - const hiddenPids = new Set(); + const hiddenPids: Set = new Set(); for (const trackIndex of hiddenGlobalTracks) { const globalTrack = globalTracks[trackIndex]; if (globalTrack.type === 'process') { diff --git a/src/selectors/profile.ts b/src/selectors/profile.ts index 38d2e68e9e..45852c231a 100644 --- a/src/selectors/profile.ts +++ b/src/selectors/profile.ts @@ -575,7 +575,7 @@ export const getLocalTrackNamesByPid: Selector> = getRawProfileSharedData, getCounters, (localTracksByPid, threads, shared, counters) => { - const localTrackNamesByPid = new Map(); + const localTrackNamesByPid: Map = new Map(); for (const [pid, localTracks] of localTracksByPid) { localTrackNamesByPid.set( pid, @@ -749,7 +749,7 @@ export const getInnerWindowIDSetByTabID: Selector> = new Map(); for (const [tabID, pages] of pagesMap) { innerWindowIDSetByTabID.set( tabID, @@ -765,7 +765,7 @@ export const getExtensionIdToNameMap: Selector | null> = return null; } - const extensionIDtoNameMap = new Map(); + const extensionIDtoNameMap: Map = new Map(); for (let i = 0; i < extensions.length; i++) { extensionIDtoNameMap.set(extensions.baseURL[i], extensions.name[i]); } @@ -834,7 +834,7 @@ export const getProfileFilterSortedPageData: Selector = export const getThreadIdToNameMap: Selector> = createSelector( getThreads, (threads) => { - const threadIdToNameMap = new Map(); + const threadIdToNameMap: Map = new Map(); for (const thread of threads) { threadIdToNameMap.set(thread.tid, getFriendlyThreadName(threads, thread)); } @@ -845,7 +845,7 @@ export const getThreadIdToNameMap: Selector> = createSelector( export const getProcessIdToNameMap: Selector> = createSelector( getThreads, (threads) => { - const processIdToNameMap = new Map(); + const processIdToNameMap: Map = new Map(); for (const thread of threads) { if (!thread.isMainThread || !thread.pid) { continue;