Closed zhc-l closed 1 month ago
qiniu版本:^7.11.1
[key: string]: string | number | boolean | undefined;
PutPolicyOptions接口定义中索引签名需要加上undefined,本地临时解决
@zhc-l 确实加上 undefined
会更严谨。会发个小版本来加上。
能否麻烦您提供一下您的 typescript 版本与 tsconfig.json?通过以下方式未能复现类型检查错误。
mkdir qiniu-nodejs-issue-432
cd qiniu-nodejs-issue-432
yarn add qiniu@7.11.1 typescript @types/node # typescirpt@5, @types/node@20
cat <<EOS > "put_policy.ts"
import * as qiniu from "qiniu";
const options: qiniu.rs.PutPolicyOptions = {
scope: 'bucket',
};
const putPolicy = new qiniu.rs.PutPolicy(options);
console.log(putPolicy.getFlags());
EOS
./node_modules/.bin/tsc put_policy.ts && node put_policy.js
{ "compilerOptions": { "lib": ["ES2015", "ES2016"], "baseUrl": "./", "outDir": "dist", "target": "esnext", "module": "CommonJS", "moduleResolution": "Node", "noImplicitAny": false, "sourceMap": false, "esModuleInterop": true, "isolatedModules": false, "forceConsistentCasingInFileNames": true, "strictPropertyInitialization": false, "strict": true, "experimentalDecorators": true, "emitDecoratorMetadata": true
}
}
"typescript": "*"
@zhc-l 建议您可以在 tsconfig.json 新增一个配置 skipLibCheck
{
"compilerOptions": {
"skipLibCheck": true
}
}
fixed in v7.12.0
mac@macdeMacBook-Pro chessAndCardRoomServer % yarn run build yarn run v1.22.19 $ rimraf dist && tsc && tsc-alias node_modules/qiniu/index.d.ts:1476:9 - error TS2411: Property 'scope' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1476 scope?: string;
node_modules/qiniu/index.d.ts:1478:9 - error TS2411: Property 'expires' of type 'number | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1478 expires?: number;
node_modules/qiniu/index.d.ts:1480:9 - error TS2411: Property 'saveKey' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1480 saveKey?: string;
node_modules/qiniu/index.d.ts:1482:9 - error TS2411: Property 'endUser' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1482 endUser?: string;
node_modules/qiniu/index.d.ts:1484:9 - error TS2411: Property 'returnBody' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1484 returnBody?: string;
node_modules/qiniu/index.d.ts:1486:9 - error TS2411: Property 'callbackHost' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1486 callbackHost?: string;
node_modules/qiniu/index.d.ts:1488:9 - error TS2411: Property 'callbackBodyType' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1488 callbackBodyType?: string;
node_modules/qiniu/index.d.ts:1491:9 - error TS2411: Property 'persistentOps' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1491 persistentOps?: string;
node_modules/qiniu/index.d.ts:1493:9 - error TS2411: Property 'persistentPipeline' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1493 persistentPipeline?: string;
node_modules/qiniu/index.d.ts:1496:9 - error TS2411: Property 'fsizeMin' of type 'number | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1496 fsizeMin?: number;
node_modules/qiniu/index.d.ts:1499:9 - error TS2411: Property 'detectMime' of type 'number | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1499 detectMime?: number;
node_modules/qiniu/index.d.ts:1501:9 - error TS2411: Property 'fileType' of type 'number | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1501 fileType?: number;
node_modules/qiniu/index.d.ts:1506:9 - error TS2411: Property 'transformFallbackMode' of type 'string | undefined' is not assignable to 'string' index type 'string | number | boolean'.
1506 transformFallbackMode?: string;
Found 26 errors in the same file, starting at: node_modules/qiniu/index.d.ts:1476