[英]TypeScript: Can I mix using “import * from” and “require(*)”
Is it ok in TypeScript to mix these too 'include' types? 在TypeScript中混合这些“包含”类型是否可以?
import { SomeType, someFunc } from "./MyThings";
And: 和:
import events = require('events');
The first would be a TypeScript module with an export or two... and the second is just a node module called events (I guess this could be anything pulled in from NPM too). 第一个是带有导出的TypeScript模块或两个...而第二个只是一个名为events的节点模块(我猜这可能是从NPM中提取的任何东西)。
Am I ok to mix these two conventions in a single TypeScript file? 我可以将这两个约定混合在一个TypeScript文件中吗?
Yes, this is acceptable in TypeScript. 是的,这在TypeScript中是可以接受的。
When using the import foo = require('foo');
使用
import foo = require('foo');
, you must have a module 'foo'
declared with declare module 'foo'
, typically in a .d.ts
file. ,你必须有一个模块
'foo'
与申报declare module 'foo'
,通常在.d.ts
文件。
This is typically covered in node.d.ts
. 这通常包含在
node.d.ts
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.