本帖最后由 jihousai 于 2022-11-4 01:00 编辑
有一个 .d.ts 文件,比如 http2.d.ts, 文件定义了一些 interface, 如下
[JavaScript] 纯文本查看 复制代码 export interface Http2Stream extends stream.Duplex {
/**
* Set to `true` if the `Http2Stream` instance was aborted abnormally. When set,
* the `'aborted'` event will have been emitted.
* [url=home.php?mod=space&uid=441028]@Since[/url] v8.4.0
*/
readonly aborted: boolean;
/**
* This property shows the number of characters currently buffered to be written.
* See `net.Socket.bufferSize` for details.
* @since v11.2.0, v10.16.0
*/
readonly bufferSize: number;
/**
* Set to `true` if the `Http2Stream` instance has been closed.
* @since v9.4.0
*/
readonly closed: boolean;
ts小白,只知道.d.ts是个类型定义文件,我想在 .js 文件中引用 Http2Stream,如下
[JavaScript] 纯文本查看 复制代码 const
{ Http2Stream} = require('http2'),
可是该怎么初始化一个 Http2Stream 对象呢?
谢谢。 |