TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

add missing interfaces for sub-classes of PerformanceEntry

Open heysujal opened this issue 1 year ago • 4 comments

Fixes #58644

The interface were missing for subclasses of PerformanceEntry which causes an error when we try to run below code snippet Playground Link

function pageWasRealoaded(): boolean {
    return performance
        .getEntriesByType('navigation')
        // Error: TS2339: Property type does not exist on type PerformanceEntry
        // This is wrong, because this is a PerformanceNavigationTiming object
        .some(entry => entry.type === 'reload');
}

I have added missing interfaces for different subclasses for every return type which can be found here. All of them inherit from PerformanceEntry interface.

I found that some interfaces were missing some properties. For example PerformanceResourceTiming.initiatorType

I think there are still changes that needs to be done. Thanks @lll000111 for guiding me. Please provide feedback.

heysujal avatar Jul 07 '24 19:07 heysujal

@microsoft-github-policy-service agree

heysujal avatar Jul 07 '24 19:07 heysujal

I have now found that I might need to add interfaces in webworker.generated.d.ts because the issue is not resolved yet. Earlier, I compiled the code to JavaScript and ran that compiled code. I missed that TypeScript compiler is still throwing the same error.

heysujal avatar Jul 07 '24 20:07 heysujal

I just found that some entry types are not supported by getEntriesByType(). See here. I added interfaces for them too, earlier. So, now I have decided to remove the getEntriesByType entries from the interface of Performance for those types that are not supported by getEntriesByType() method

heysujal avatar Aug 04 '24 10:08 heysujal

@RyanCavanaugh The issue is still not solved, can you please help me with this? Update : I will start working on this again.

heysujal avatar Aug 04 '24 12:08 heysujal