Sergino
Sergino

Reputation: 10818

vscode autocomplete not working on methods in typescript

I am code with vscode using typescript. Everything working perfect except I do not have an autocomplete on methods in my app.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

enter image description here

But after I type . vscode is not giving any app. Request.

enter image description here

I have all td installed. My tsconfig.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?

Upvotes: 2

Views: 3010

Answers (1)

basarat
basarat

Reputation: 276191

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

Upvotes: 11

Related Questions