VS代码中Firebase的代码完成?

Alq*_*qin 2 javascript intellisense firebase typescript visual-studio-code

此视频上, Typescript用于代码完成。我按照此处的说明进行操作,并让Typescript处理Hello World示例。我不知道下一步该怎么做才能完成Firebase的代码。

如何在VS Code中获得Firebase的代码完成?

更新1

我在VS代码终端中使用以下命令创建了Firebase项目:firebase initfirebase init functions。因此,我还想说代码完成可以在必须创建的functions / index.ts文件中工作,只是说一下。

然后我做了npm init,并且很谦虚:

npm install --save-dev @types/firebase
Run Code Online (Sandbox Code Playgroud)

现在,在项目的根目录中,我具有node_module@types/firebase包含内容的目录以及此package.json文件:

{
  "name": "My Project",
  "version": "1.0.0",
  "description": "Does something",
  "main": "index.js",
  "dependencies": {},
  "devDependencies": {
    "@types/firebase": "^2.4.31"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Somebody",
  "license": "ISC"
}
Run Code Online (Sandbox Code Playgroud)

我还创建了一个index.ts文件进行测试,但是当我键入firebase.没有代码完成时。要完成代码的下一步是什么?

更新2

.vscode / tasks.json:

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "0.1.0",
  "command": "tsc",
  "isShellCommand": true,
  "args": ["-w", "-p", "."],
  "showOutput": "silent",
  "isBackground": true,
  "problemMatcher": "$tsc-watch"
}
Run Code Online (Sandbox Code Playgroud)

tsconfig.json:

{
    "compilerOptions": {
        "target": "es5", 
        "sourceMap": true
    }    
}
Run Code Online (Sandbox Code Playgroud)

仍然没有代码完成!

更新3

functions/index.ts我有兴趣看到代码完成的文件的开头:

import * as firebase from 'firebase';
var functions = require('firebase-functions');
Run Code Online (Sandbox Code Playgroud)

import * as firebase from 'firebase'部分来自此视频,在那里我看到了代码完成的工作。我还希望代码完成在public/app.ts客户端文件中工作。

Oli*_*Oli 5

我在函数/index.ts的开头使用

import functions = require('firebase-functions'); import admin = require('firebase-admin');

而且有效。

  • 我从样本中获得的代码具有const函数= require(...)。更改const来导入对我有用。谢谢! (3认同)