I am using TypeScript with Express
/Node.js
.
For consuming modules, the TypeScript Handbook shows the following syntax:
import express = require('express');
But also the typescript.d.ts
file shows:
import * as express from "express";
I also searched the MSDN blog but could not find anything.
Which one is more correct as of early 2016? What are the differences between the two, if any?
Where is the best source to find information on the latest syntax to use so I can find this information in the future?
This question is related to
javascript
node.js
express
typescript
import * as express from "express";
This is the suggested way of doing it because it is the standard for JavaScript (ES6/2015) since last year.
In any case, in your tsconfig.json file, you should target the module option to commonjs which is the format supported by nodejs.
Source: Stackoverflow.com