[英]TypeScript definition for createReadStream won't accept {start: 90, end: 99 } in the options
I just updated to TypeScript 1.6.2 and my call to createReadStream() won't compile because the type definition in node.d.ts does not expect 'start' and 'end' in the options parameter. 我刚刚更新到TypeScript 1.6.2,由于对node.d.ts中的类型定义不期望options参数中的“开始”和“结束”,因此对createReadStream()的调用将无法编译。
var st = fs.createReadStream(logFile , {start: rstart, end: rend } );
will get this error: 将得到此错误:
error TS2345: Argument of type '{ start: number; end: number; }' is not assignable to parameter of type '{ flags?: string; encoding?: string; fd?: string; mode?: string; bufferSize?: number; }'.
Since the documentation does mention these as valid options ( https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options ) I do believe the node.d.ts should be fixed and I can issue a pull request with the fix, but - in the meantime - is there a way to force this call to pass the compiler? 由于文档确实提到了这些作为有效的选项( https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options ),所以我确实认为node.d.ts应该是固定的,我可以通过该固定发出拉取请求,但是-同时-有没有办法强制此调用通过编译器?
thanks 谢谢
I do believe the node.d.ts should be fixed and I can issue a pull request with the fix, but - in the meantime - is there a way to force this call to pass the compiler?
我确实认为node.d.ts应该是固定的,并且可以通过该修订发出请求请求,但是-同时-有没有办法强制此调用通过编译器?
You can assert it as any
for now: 可以断言它作为
any
现在:
var st = fs.createReadStream(logFile, {start: rstart, end: rend } as any);
Or manually update your local node.d.ts
to include those properties. 或手动更新您的本地
node.d.ts
以包括这些属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.