From ab0d6c359c13aacd1e731d236f489e368311161d Mon Sep 17 00:00:00 2001 From: gxkl Date: Mon, 21 Oct 2024 20:14:38 +0800 Subject: [PATCH] fix: type --- src/OSSBaseClient.ts | 2 +- src/error/OSSClientError.ts | 1 + test/OSSObject.test.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OSSBaseClient.ts b/src/OSSBaseClient.ts index 0e7fabd0a..090214ebf 100644 --- a/src/OSSBaseClient.ts +++ b/src/OSSBaseClient.ts @@ -311,7 +311,7 @@ export abstract class OSSBaseClient { // https://help.aliyun.com/zh/oss/support/http-status-code-409#section-rmc-hvd-j38 if (info?.Code === 'PositionNotEqualToLength' && result.headers['x-oss-next-append-position']) { - (err as any).nextAppendPosition = result.headers['x-oss-next-append-position']; + err.nextAppendPosition = result.headers['x-oss-next-append-position'] as string; } } diff --git a/src/error/OSSClientError.ts b/src/error/OSSClientError.ts index f0d363d08..d4a757c4e 100644 --- a/src/error/OSSClientError.ts +++ b/src/error/OSSClientError.ts @@ -7,6 +7,7 @@ export class OSSClientError extends Error { status: number; requestId?: string; hostId?: string; + nextAppendPosition?: string; constructor(status: number, code: string, message: string, requestId?: string, hostId?: string) { super(`[${REQUEST_ID_KEY}=${requestId}, ${RESPONSE_CODE_KEY}=${code}, ${RESPONSE_HOST_KEY}=${hostId}] ${message}`); diff --git a/test/OSSObject.test.ts b/test/OSSObject.test.ts index e95cf5728..77bf19629 100644 --- a/test/OSSObject.test.ts +++ b/test/OSSObject.test.ts @@ -406,7 +406,7 @@ describe('test/OSSObject.test.ts', () => { assert.equal(err.name, 'OSSClientError'); assert.equal(err.code, 'PositionNotEqualToLength'); assert.equal(err.status, 409); - assert.equal((err as any).nextAppendPosition, '3'); + assert.equal(err.nextAppendPosition, '3'); assert.match(err.message, /Position is not equal to file length/); return true; });