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
But after I type .
vscode is not giving any app.
Request.
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?
Is there any way to fix that?
Yes. Instead of :
var express = require('express');
You should use import/require
:
import express = require('express');
https://basarat.gitbooks.io/typescript/content/docs/project/modules.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.