【发布时间】:2018-08-21 16:50:12
【问题描述】:
对于 TypeScript 2.7.2,在带有 @types/express 和随后代码的 VSCode 版本 1.21 中,在某些情况下 VSCode 会抛出错误说明
A namespace-style import cannot be called or constructed, and will cause a failure at runtime.
但是,在其他具有类似设置和类似tsconfig.json 文件的机器上,该代码可以正常工作。这里发生了什么...
import { Bank } from './Bank';
import * as Express from 'express'; <== errors here..
let app: Express.Express;
this.app = Express(); <== and here
为什么会这样?
TIA,
约翰。
【问题讨论】:
-
除了@fathyb 的回答之外,您可能还需要在
tsconfig.json中启用allowSyntheticDefaultImports
标签: typescript express typescript-typings