小编Spe*_*cer的帖子

如何调试已安装的 VSCode 扩展?

在凌动,我能够调试安装的扩展通过打开开发者工具(Option+ Cmd+ I),并通过JavaScript文件浏览~/.atom/packages,如

Atom 开发者工具

是否可以在 VSCode 中执行此操作?通过Help -> Toggle Developer Tools打开开发者工具后,我能找到的唯一与扩展相关的文件是图标图像:

VSCode 开发者工具

visual-studio-code vscode-extensions

6
推荐指数
2
解决办法
2658
查看次数

如何使用node-webkit中的webpack将节点模块与本机插件捆绑在一起?

我正在尝试构建pty.js以便在node-webkit(即nw.js)v0.8.6中使用:

mkdir testapp && cd testapp
nvm use 0.10.36
npm install -g nw-gyp
npm install pty.js
cd node_modules/pty.js

# Build the native addon for node-webkit v0.8.6:
nw-gyp configure --target=0.8.6 && nw-gyp build
Run Code Online (Sandbox Code Playgroud)

输出结束gyp info ok.

使用简单的app.jsindex.html,应用程序在JavaScript控制台中启动时没有错误:

<!-- index.html -->

<!DOCTYPE html>
<html>
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    <script src="app.js"></script>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)
// app.js

var pty = require('pty.js');

var term = pty.spawn('bash', [], {
  name: …
Run Code Online (Sandbox Code Playgroud)

node.js node-webkit webpack

5
推荐指数
1
解决办法
2054
查看次数

TypeScript:根据字符串文字属性一般推断联合类型成员

TypeScript (v3.2.2) 允许我定义接口的联合,每个接口都有一个唯一的字符串文字属性,可以用作类型保护,例如

type Device = Laptop | Desktop | Phone;

interface Laptop {
  type: 'Laptop';
  countDriveBays: number;
  hasTouchScreen: boolean;
}

interface Desktop {
  type: 'Desktop';
  countDriveBays: number;
}

interface Phone {
  type: 'Phone';
  hasTouchScreen: boolean;
}

function printInfo(device: Device) {
  if (device.type === 'Laptop') {
    // device: Laptop
    console.log(
      `A laptop with ${device.countDriveBays} drive bays and ${
        device.hasTouchScreen ? 'a' : 'no'
      } touchscreen.`,
    );
  } else if (device.type === 'Desktop') {
    // device: Desktop
    console.log(`A desktop with ${device.countDriveBays} …
Run Code Online (Sandbox Code Playgroud)

typescript typescript3.0

5
推荐指数
2
解决办法
1687
查看次数