TencentCloud / TencentCloud/tencentcloud-sdk-nodejs
refactor: 把 namespace 当函数调用
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 600
- Forks
- 113
- Avg merge
- 6h 46m
- Merged PRs (30d)
- 1
Description
气不过,想了想还是提一嘴吧。
(!) 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),还请慢慢修复。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the library examples and exports, then inspect src/common/sign.ts and src/common/http/http_connection.ts where namespace imports are called. Check for similar occurrences in the library, and finish when the imports match the library API, the namespace-call diagnostics are gone, and isObject uses unknown with a TypeScript type predicate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100