我的代码是vscode
using typescript
。
一切都很完美,除了我的方法中没有自动完成功能app.ts
但是,如果我打开自动生成的文件 app.js,那么我就看不到那里的自动完成问题。
这是我的app.ts
/// <reference path="./typings/tsd.d.ts"/>
import {Request, Response} from 'express';
var express = require('express');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var app = express();
然后在输入第一个单词时我会自动完成它
但当我输入后.
vscode 没有给出任何app.
Request.
我都有td
安装。
我的tsconfig.json
:
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"watch": true
},
"exclude": [
"node_modules"
]
}
有什么办法可以解决这个问题吗?
有什么办法可以解决这个问题吗?
是的。代替 :
var express = require('express');
你应该使用import/require
:
import express = require('express');
Docs
https://basarat.gitbooks.io/typescript/content/docs/project/modules.html https://basarat.gitbooks.io/typescript/content/docs/project/modules.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)