I use electron, typescript, react with preload.
env
"electron": "19.0.6",
"electron-builder": "23.1.0",
"typescript": "4.7.4",
dir
root - public / preload.ts
|____ src / main.tsx
|____ common.d.ts
<common.d.ts>
export interface ItestAPI{
load:() => Promise<void>
}
declare global{
interface Window{
testAPI: ItestAPI
}
}
<main.tsx>
export function Main(){
async function handleClick(){
await window.testAPI.load();
}
return(
...
<btn onClick={handleClick}>
...
)
}
<preload.ts>
I guess preload and main both refer to same window because it runs well.
If so, why preload.ts shows me red line(error) ?
