MDNのPerformanceNavigation.typeに記載の通り、次のソースコードはVSCode上で非推奨と提示される。
const isNavigate = window?.performance?.navigation?.type === 0;
PerformanceNavigationTimingの利用は正解ですが、具体的な使い方がよく分からなかった。
調べた結果、Performance.getEntriesByType()で次のように行ける。
const isNavigate = window?.performance?.getEntriesByType('navigation')[0].type === 'navigate';
window?.performance.getEntries()
では全てのエントリーを調べられる。