Skip to content

Cannot find name 'BrowserWindow' #258

@Oleg1983

Description

@Oleg1983

In folder providers in electron.service.ts I have problem:

import { Injectable } from '@angular/core';

// If you import a module but never use any of the imported values other than as TypeScript types,
// the resulting javascript file will look as if you never imported the module at all.
import { ipcRenderer, webFrame, remote, BrowserWindow } from 'electron';
import * as childProcess from 'child_process';
import * as fs from 'fs';

@Injectable()
export class ElectronService {

  ipcRenderer: typeof ipcRenderer;
  webFrame: typeof webFrame;
  remote: typeof remote;
  childProcess: typeof childProcess;
  win: BrowserWindow;
  fs: typeof fs;

  constructor() {
    // Conditional imports
    if (this.isElectron()) {
      this.ipcRenderer = window.require('electron').ipcRenderer;
      this.webFrame = window.require('electron').webFrame;
      this.remote = window.require('electron').remote;
      this.win = window.require('electron').remote.getCurrentWindow();

      this.childProcess = window.require('child_process');
      this.fs = window.require('fs');
    }
  }

  isElectron = () => {
    return window && window.process && window.process.type;
  }
}

screenshot_6
When I write in my project
win: BrowserWindow;
I get error Cannot find name 'BrowserWindow'. What is wrong? I did
import { ipcRenderer, webFrame, remote, BrowserWindow } from 'electron';
I can't rewrite instead win: typeof BrowserWindow;
because in method toggleFullScreen() will not be to able method isFullScreen(), show(),setFullScreen().
screenshot_7
App work good in develop mode, but I have error and I can't build exe file. How fix that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions