Skip to content

Conversation

@heysujal
Copy link

@heysujal heysujal commented Jul 7, 2024

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.

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jul 7, 2024
@heysujal
Copy link
Author

heysujal commented Jul 7, 2024

@microsoft-github-policy-service agree

@heysujal heysujal marked this pull request as draft July 7, 2024 19:52
@heysujal
Copy link
Author

heysujal commented Jul 7, 2024

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 heysujal marked this pull request as ready for review July 11, 2024 12:20
@heysujal
Copy link
Author

heysujal commented Aug 4, 2024

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
Copy link
Author

heysujal commented Aug 4, 2024

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

@heysujal heysujal closed this Dec 4, 2024
@sandersn sandersn removed this from PR Backlog Apr 22, 2025
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TS 5.4.5: Return type for performance.getEntriesByType is inaccurate

2 participants