var someModule = require('someModule')
は一般的にimport * as someModule from 'someModule'
に置き換えられますが、Typescript/ES6構文を使って次のNode.jsコードを表現する方法を理解できません。プロパティ 'サーバー'が 'typeof "http"' type32に存在しません
var server = require('http').Server(app);
import and call a function with es6 を読んだ後、私は次のことを試してみました:
import * as httpModule from 'http';
const server = httpModule.Server(app);
をして、コードをコンパイルし、正しく実行行いますが、私はまだ、このエラーを取得TS:
[ts] Property 'Server' does not exist on type 'typeof "http"'
。
私は@タイプ/ノードと@タイプ/エクスプレスがインストールされています。何か不足していますか?
import { Server, createServer } from 'http';
const server = createServer(app);
@Felix Kling私は私の質問を編集しており、もはやhttps://stackoverflow.com/questions/31599566/import-and-call-a-function-with-es6の複製ではないと信じています。 – neoflash