How to get intellisense for express.js in vscode

时间:2017-12-18 07:52:54

标签: node.js express web server visual-studio-code

I have tried installing type definitions with :-

My code is in NSMutableArray *aryXMLName = [NSMutableArray new]; [aryXMLName addObject:@"test"]; [aryXMLName addObject:@"text1"]; for(NSString *str in aryXMLName){ NSString *path = [[NSBundle mainBundle] pathForResource:str ofType:@"xml"]; NSLog(@"Path : %@",path); NSData *data=[NSData dataWithContentsOfFile:path]; if ([str isEqualToString:@"test"]) { if (data == nil) return; NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"string: %@", str); NSDictionary *xmlDoc = [NSDictionary dictionaryWithXMLString:str]; NSLog(@"dictionary: %@", xmlDoc); }else if ([str isEqualToString:@"text1"]){ if (data == nil) return; NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"string: %@", str); NSDictionary *xmlDoc = [NSDictionary dictionaryWithXMLString:str]; NSLog(@"dictionary: %@", xmlDoc); } } javascript file.

server.js

But still it doesn't seem to give intellisense for app after instantiating express .

But when I use express like this :

npm install @types/express

I am not getting the codecompletion or intellisense for app instance of express.

How to fix this ?

3 个答案:

答案 0 :(得分:0)

VS Code编辑器支持许多编程语言(例如Javascript,TypeScript,JSON,HTML,CSS,Less和Sass)的代码自动完成。至于其他编程语言,您可能需要去安装插件。

要获取自动完成功能,请键入一个关键字,然后按Ctrl + space键以获取代码自动完成建议,如下所示。

enter image description here

但是,如果仍然无法使用,则需要返回并检查设置。去 File-> Preferences-> Settings会打开一个窗口,您可以在其中更改一些首选项

enter image description here

,然后在本节中转到“文本编辑器和建议”,检查快速建议(例如是否已启用)的设置是什么,以及建议出现的延迟时间是多少,您可以对其进行更改并检查是否是否工作。希望这会有所帮助。

答案 1 :(得分:0)

我的回答有很多延迟,但是在这里:

您正在使用.js文件,因此该文件上不存在类型。通过npm安装@ types / something依赖项时,这允许您使用类型,但只能在Typescript中使用。

答案 2 :(得分:0)

导入此代码:

/ ** @type {import(“ express”)。RequestHandler} * /

相关问题