包.json
{
"type": "module",
"dependencies": {
"@types/node": "^18.6.5",
"typescript": "^4.7.4"
}
}
Run Code Online (Sandbox Code Playgroud)
tsconfig.json
{
"compilerOptions": {
"target": "ES2021",
"module": "ESNext",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
Run Code Online (Sandbox Code Playgroud)
使用节点 v18.7.0,我尝试将从本机 fetch API 返回的网络流转换为节点流。我使用“node:stream”模块中的 Readable.fromWeb 方法。Typescript 返回类型检查错误,但代码使用 @ts-ignore 注释按预期工作。
类型错误
Argument of type 'ReadableStream<Uint8Array>' is not assignable to parameter of type 'ReadableStream<any>'.
Type 'ReadableStream<Uint8Array>' is missing the following properties from type 'ReadableStream<any>': values, [Symbol.asyncIterator]
const nodeStream = Readable.fromWeb(fetchRequest.body)
Run Code Online (Sandbox Code Playgroud)
源代码
Argument of type 'ReadableStream<Uint8Array>' is not assignable to parameter of …Run Code Online (Sandbox Code Playgroud) Redis 文档似乎确认 EVAL 脚本也与 MULTI/EXEC 事务类似。
用我个人的话来说,这意味着 LUA 脚本保证了两件事:
(我对第二点不关心 MULTI/EXEC,因为使用 MULTI/EXEC 你不能根据以前的命令进行写入)
(对不起,我的英语基础不好,我是法国人)
atomic ×1
crash ×1
eval ×1
fetch-api ×1
lua ×1
node-streams ×1
node.js ×1
redis ×1
typescript ×1