@@ -9,13 +9,39 @@ import "./App.scss";
99import React from "react" ;
1010import Overview from "./components/Overview" ;
1111
12+ // ==============================
13+ // Global augmentations
14+ // ==============================
15+
16+ declare global {
17+ interface Window {
18+ // Global injected app data (loaded via @data in dev and via index.html in prod).
19+ data : unknown ;
20+ }
21+ }
22+
23+ // ==============================
24+ // Component props
25+ // ==============================
26+
27+ interface AppProps {
28+ // Callback that is forwarded to Overview. We keep it generic here
29+ // because the exact payload type is defined by Overview.
30+ onStatsReady ?: ( stats : unknown ) => void ;
31+ }
32+
1233if ( process . env . NODE_ENV !== "production" ) {
1334 // Load example data for development
14- window . data = require ( "@data" ) ;
15- window . data . version = "(development build)" ;
35+ // `require` is used here intentionally because @data is only available in dev builds.
36+ // eslint-disable-next-line @typescript-eslint/no-var-requires
37+ window . data = require ( "@data" ) as unknown ;
38+
39+ // `window.data` is `unknown` on purpose (shape depends on runtime data).
40+ // We keep the original behavior and only narrow locally for this assignment.
41+ ( window . data as { version ?: string } ) . version = "(development build)" ;
1642}
1743
18- const App = ( props ) => {
44+ const App = ( props : AppProps ) : JSX . Element => {
1945 // If we visit this page without a hash, like www.domain.com/ or www.domain.com/subpage, we
2046 // append a hash to the URL to ensure that the page is loaded correctly. This is necessary
2147 // to ensure correct routing in the app.
0 commit comments