使用Typescript导入Electron类

时间:2015-07-08 19:43:37

标签: typescript electron

如何将Electron类导入到Typescript文件中,以便intellisense正常运行?

例如,我想转此:

var BrowserWindow = require('browser-window');
var app = require('app');
app.on("ready", function() {
  var mainWindow = new BrowserWindow({
    width: 600,
    height: 800
  });
});

这样的事情(不起作用):

/// <reference path="./typings/github-electron/github-electron.d.ts"/>
var app = GitHubElectron.App;
app.on("ready", function() {
  var mainWindow = new GitHubElectron.BrowserWindow({
    width: 600,
    height: 800
  });
});

1 个答案:

答案 0 :(得分:2)

library(XML) # read in the XML (I'm doing it from clipboard, you do it however suits you). # You need useInternalNodes=T though. doc <- xmlTreeParse(readLines('clipboard',warn=F), useInternalNodes=T) # get `p` elements that are not inside a `table` element, and # add a '.' to the end of the text. xpathApply(doc, "//p[not(ancestor::table)]", function (p) xmlValue(p) <- paste0(xmlValue(p), '.') ) # type 'doc' to inspect the output # could write it out now, for example saveXML(doc, file='output.xml') 函数调用的返回值使用类型注释:

require