-
I'm currently working on a monorepo and I've been having issues with types that I can't find a solution at all. First that I'm not using the preload/src/index.ts import { contextBridge } from 'electron';
import { sha256sum } from 'nodeCrypto';
import { versions } from 'versions';
const API = {
versions,
sha256sum,
};
contextBridge.exposeInMainWorld('api', API);
export type API = typeof API; preload/types/preload.d.ts import type { API } from '../src/index';
declare global {
interface Window {
api: API;
test: number;
}
} renderer/tsconfig.json {
"extends": "tsconfig/react.json",
"compilerOptions": {
"baseUrl": "./src"
},
"include": [
"./src/**/*.ts",
"./src/**/*.tsx",
"../../types/**/*.d.ts",
"../preload/types/**/*.d.ts" // <-- added this
]
} renderer/src/components/ElectronVersions.tsx export const ElectronVersions = () => {
console.log(window.api.versions); // <-- versions is of type any
return <ul>{window.test}</ul>; // <-- test is of type number
}; First and foremost, everything is working, both in dev and during build. The issue I have is that for some reason the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
In my opinion thats is: |
Beta Was this translation helpful? Give feedback.
-
Renaming the API and its type fixed the issue. See this. |
Beta Was this translation helpful? Give feedback.
Renaming the API and its type fixed the issue. See this.