VS code自动完成不工作的打字稿方法 [英] vscode autocomplete not working on methods in typescript
问题描述
我code与 VS code
使用打字稿
。
一切都完美的工作,除了我没有在我的 app.ts
但是如果我打开app.js这是自动生成的文件,所以我可以看到自动完成没有问题的方法自动完成那里。
下面是我的 app.ts
///<参考路径=./分型/ tsd.d.ts/>
进口{请求,响应}从前preSS';
VAR前preSS =要求('前preSS');
VAR记录=要求('摩根');
VAR cookieParser =要求('cookie的解析器');
VAR bodyParser =要求('身体分析器');
VAR应用=前preSS();
然后上输入第一个字我得到它的自动完成
但是在我键入。
VS code未给予任何应用程序。
请求。
我把所有 D
安装。
我的 tsconfig.json
:
{
compilerOptions:{
目标:ES5
模块:CommonJS的
sourceMap:真实,
emitDecoratorMetadata:真实,
experimentalDecorators:真实,
removeComments:假的,
noImplicitAny:假的,
看:真
},
排除:[
node_modules
]
}
有没有办法解决呢?
有没有办法解决呢?
块引用>是的。相反的:
VAR前preSS =要求('前preSS');
您应该使用
导入/要求
:进口前preSS =要求('前preSS');
文件
https://basarat.gitbooks.io/typescript/content/文档/项目/ modules.html
I am code with
vscode
usingtypescript
. Everything working perfect except I do not have an autocomplete on methods in myapp.ts
however if I open app.js which is automatically generated file so I can see no issues with autocomplete there.Here is my
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();
Then on typing first word I am getting autocomplete on it
But after I type
.
vscode is not giving anyapp.
Request.
I have all
td
installed. Mytsconfig.json
:{ "compilerOptions": { "target": "ES5", "module": "commonjs", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false, "watch": true }, "exclude": [ "node_modules" ] }
Is there any way to fix that?
解决方案Is there any way to fix that?
Yes. Instead of :
var express = require('express');
You should use
import/require
:import express = require('express');
Docs
https://basarat.gitbooks.io/typescript/content/docs/project/modules.html
这篇关于VS code自动完成不工作的打字稿方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!