csepulv / electron-with-create-react-app

Sample Electron application using create-react-app
MIT License
831 stars 217 forks source link

Last package.json for ts. #28

Open bitrix1 opened 5 years ago

bitrix1 commented 5 years ago
{
  "name": "react-test",
  "version": "0.1.0",
  "private": true,
  "homepage": "./",
  "main": "src/electron-starter.js",
  "resolutions": {
    "@types/react": "^16.8.6"
  },
  "dependencies": {
    "electron": "^4.0.6",
    "react": "^16.8.3",
    "react-dom": "16.8.3"
  },
  "scripts": {
    "start": "react-scripts-ts start",
    "build": "react-scripts-ts build",
    "test": "react-scripts-ts test --env=jsdom",
    "eject": "react-scripts-ts eject",
    "electron": "electron ."
  },
  "devDependencies": {
    "@types/react-dom": "^16.8.2",
    "@types/electron": "^1.6.10",
    "@types/jest": "^24.0.9",
    "@types/node": "^11.10.4",
    "@types/react": "^16.8.6",
    "foreman": "^2.0.0",
    "react-scripts-ts": "3.1.0",
    "typescript": "^3.3.3333"
  }
}
bitrix1 commented 5 years ago

Import window as any in App.tsx

const electron = (window as any).require('electron');
const fs = electron.remote.require('fs');
console.log('electron', electron);
const ipcRenderer = electron.ipcRenderer;
gautamsi commented 5 years ago

I have tried this, problem is that it removes Type information and TypeScript is now clueless.

csepulv commented 5 years ago

Unfortunately I have no experience with Typescript, so I can't offer a suggestion on how to get this working with it.

gautamsi commented 5 years ago

this was for @bitrix1