Skip to content

refactor: 把 namespace 当函数调用 #229

@FurryR

Description

@FurryR

气不过,想了想还是提一嘴吧。

(!) Cannot call a namespace ('JSONBigInt')
src/common/sign.ts (6:22)
4: import * as JSONBigInt from "json-bigint"
5:
6: const JSONbigNative = JSONBigInt({ useNativeBigInt: true })
                         ^
7:
8: /**
(!) Cannot call a namespace ('JSONBigInt')
src/common/http/http_connection.ts (12:22)
10: import * as JSONBigInt from "json-bigint"
11:
12: const JSONbigNative = JSONBigInt({ useNativeBigInt: true })
                          ^
13: /**
14:  * @inner
(!) Cannot call a namespace ('isStream')
src/common/http/http_connection.ts (180:8)
178: async function convertReadStreamToBuffer(data: any): Promise<void> {
179:   for (const key in data) {
180:     if (isStream(data[key])) {
             ^
181:       data[key] = await getStream.buffer(data[key])
182:     }
(!) Cannot call a namespace ('isStream')
src/common/http/http_connection.ts (227:50)
225:
226: function isObject(x: any): boolean {
227:   return typeof x === "object" && !isArray(x) && !isStream(x) && !isBuffer(x) && x !== null
                                                       ^
228: }

见过 CJS require 见过 default import,还没见过全导入进来当函数调用的。请根据库自己的 example 和 export 来修改代码。
另外我注意到 http_connection.ts 的 isObject 属最差实践,应该使用 Typescript is 语法来对 x 进行约束。并将 x 的参数类型改为 unknown。库本身可能存在很多处这样的问题,恕我不能一一指出(贵司未配置 eslint),还请慢慢修复。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions