From 7529dd40f0730b38cbae33dbd7e920739967731a Mon Sep 17 00:00:00 2001 From: Martin Sajti Date: Fri, 30 May 2025 12:44:51 +0200 Subject: [PATCH] Fix invlid code after primitive type refactor Change-Id: I0615ceabceb8503b09b036dbbb595fe63eda1bc7 Signed-off-by: Martin Sajti --- .../js/src/mod_fs/ani/ets/@ohos.file.fs.ets | 378 +++++++++--------- .../src/mod_hash/ani/ets/@ohos.file.hash.ets | 8 +- .../ani/ets/@ohos.file.securityLabel.ets | 16 +- 3 files changed, 201 insertions(+), 201 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets b/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets index 5de05d13c..46b8bbed4 100644 --- a/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets +++ b/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets @@ -47,8 +47,8 @@ function access(path: string, mode?: AccessModeType): Promise { promise.then((ret: NullishType): void => { let result = ret as boolean; resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -62,8 +62,8 @@ function access(path: string, callback: AsyncCallback): void { e.code = 0; let result = ret as boolean; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, false); + }).catch((e: Error): void => { + callback(e as BusinessError, false); }); } @@ -75,8 +75,8 @@ function access(path: string, mode: AccessModeType, flag: AccessFlagType): Promi promise.then((ret: NullishType): void => { let result = ret as boolean; resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }) } @@ -94,8 +94,8 @@ function close(file: number | File): Promise { let promise = taskpool.execute((file: number | File): undefined => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -106,8 +106,8 @@ function close(file: number | File, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -121,8 +121,8 @@ function connectDfs(networkId: string, listeners: DfsListeners): Promise { FileIoImpl.connectDfs(networkId, listeners), networkId, listeners); promise.then((): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -132,8 +132,8 @@ function disconnectDfs(networkId: string): Promise { let promise = taskpool.execute((networkId: string): void => FileIoImpl.disConnectDfs(networkId), networkId); promise.then((): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -150,8 +150,8 @@ function getxattr(path: string, key: string): Promise { promise.then((ret: NullishType): void => { let result = ret as string; resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -171,8 +171,8 @@ function copyDir(src: string, dest: string, mode?: number): Promise { FileIoImpl.copyDirSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError>): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError>); }); }); } @@ -185,8 +185,8 @@ function copyDir(src: string, dest: string, callback: AsyncCallback(0); callback(e, undefined); - }).catch((e: BusinessError>): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError>, undefined); }); } @@ -198,8 +198,8 @@ function copyDir(src: string, dest: string, mode: number, callback: AsyncCallbac e.code = 0; e.data = new Array(0); callback(e, undefined); - }).catch((e: BusinessError>): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError>, undefined); }); } @@ -237,7 +237,7 @@ function fdatasync(fd: number): Promise { let promise = taskpool.execute((fd: number): undefined => FileIoImpl.fdatasyncSync(fd), fd); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { + }).catch((e: Error): void => { reject(e as BusinessError); }); }); @@ -249,8 +249,8 @@ function fdatasync(fd: number, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -273,7 +273,7 @@ function mkdir(path: string): Promise { let promise = taskpool.execute((path: string): undefined => mkdirSync1(path), path); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { + }).catch((e: Error): void => { reject(e as BusinessError); }); }); @@ -285,8 +285,8 @@ function mkdir(path: string, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -309,8 +309,8 @@ function mkdir(path: string, recursion: boolean, callback: AsyncCallback): let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -326,8 +326,8 @@ function moveDir(src: string, dest: string, mode?: number): Promise { }, src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError>): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError>); }); }) } @@ -341,8 +341,8 @@ function moveDir(src: string, dest: string, callback: AsyncCallback(0); callback(e, undefined); - }).catch((e: BusinessError>): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError>, undefined); }); } @@ -355,8 +355,8 @@ function moveDir(src: string, dest: string, mode: number, callback: AsyncCallbac e.code = 0; e.data = new Array(0); callback(e, undefined); - }).catch((e: BusinessError>): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError>, undefined); }); } @@ -393,8 +393,8 @@ function mkdtemp(prefix: string): Promise { promise.then((ret: NullishType): void => { let result = ret as string; resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -408,8 +408,8 @@ function mkdtemp(prefix: string, callback: AsyncCallback): void { e.code = 0; let result = ret as string; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, ""); + }).catch((e: Error): void => { + callback(e as BusinessError, ""); }); } @@ -424,8 +424,8 @@ function moveFile(src: string, dest: string, mode?: number): Promise { }, src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -438,8 +438,8 @@ function moveFile(src: string, dest: string, mode: number, callback: AsyncCallba let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -451,8 +451,8 @@ function moveFile(src: string, dest: string, callback: AsyncCallback): voi let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -468,8 +468,8 @@ function open(path: String, mode?: number): Promise { promise.then((ret: NullishType): void => { let file = ret as File; resolve(file); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -483,9 +483,9 @@ function open(path: String, mode: number, callback: AsyncCallback): e.code = 0; let file = ret as File; callback(e, file); - }).catch((e: BusinessError): void => { + }).catch((e: Error): void => { let f: File = new FileInner(0); - callback(e, f); + callback(e as BusinessError, f); }); } @@ -498,9 +498,9 @@ function open(path: String, callback: AsyncCallback): void { e.code = 0; let file = ret as File; callback(e, file); - }).catch((e: BusinessError): void => { + }).catch((e: Error): void => { let f: File = new FileInner(0); - callback(e, f); + callback(e as BusinessError, f); }); } @@ -516,8 +516,8 @@ function write(fd: number, buffer: string | ArrayBuffer, options?: WriteOptions) promise.then((ret: NullishType): void => { let result = ret as number resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -532,8 +532,8 @@ function write(fd: number, buffer: string | ArrayBuffer, options: WriteOptions, e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -546,8 +546,8 @@ function write(fd: number, buffer: string | ArrayBuffer, callback: AsyncCallback e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -563,8 +563,8 @@ function read(fd: number, buffer: ArrayBuffer, options?: ReadOptions): Promise { let result = ret as number; resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -578,8 +578,8 @@ function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -592,8 +592,8 @@ function read(fd: number, buffer: ArrayBuffer, options: ReadOptions, callback: A e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -610,8 +610,8 @@ function readLines(filePath: string, options?: Options): Promise promise.then((ret: NullishType): void => { let it = ret as ReaderIterator; resolve(it); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -625,9 +625,9 @@ function readLines(filePath: string, callback: AsyncCallback): v e.code = 0; let it = ret as ReaderIterator; callback(e, it); - }).catch((e: BusinessError): void => { + }).catch((e: Error): void => { let r: ReaderIterator = new ReaderIteratorInner(0); - callback(e, r); + callback(e as BusinessError, r); }); } @@ -640,9 +640,9 @@ function readLines(filePath: string, options: Options, callback: AsyncCallback { + }).catch((e: Error): void => { let r: ReaderIterator = new ReaderIteratorInner(0); - callback(e, r); + callback(e as BusinessError, r); }); } @@ -656,8 +656,8 @@ function rmdir(path: string): Promise { let promise = taskpool.execute((path: string): void => FileIoImpl.rmdirSync(path), path); promise.then((ret: NullishType) => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -668,8 +668,8 @@ function rmdir(path: string, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -684,8 +684,8 @@ function truncate(file: string | number, len?: number): Promise { }, file, len); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }) } @@ -698,8 +698,8 @@ function truncate(file: string | number, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -711,8 +711,8 @@ function truncate(file: string | number, len: number, callback: AsyncCallback(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -726,8 +726,8 @@ function unlink(path: string): Promise { let promise = taskpool.execute((path: string): undefined => unlinkSync(path), path); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -738,8 +738,8 @@ function unlink(path: string, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -751,9 +751,9 @@ function readText(filePath: string, options?: ReadTextOptions): Promise promise.then((ret: NullishType): void => { let r = ret as string; resolve(r); - }).catch((e: BusinessError): void => { - reject(e); - }); + }).catch((e: Error): void => { + reject(e as BusinessError); + }); }); } @@ -766,8 +766,8 @@ function readText(filePath: string, callback: AsyncCallback): void { e.code = 0; let r = ret as string; callback(e, r); - }).catch((e: BusinessError): void => { - callback(e, ""); + }).catch((e: Error): void => { + callback(e as BusinessError, ""); }); } @@ -780,8 +780,8 @@ function readText(filePath: string, options: ReadTextOptions, callback: AsyncCal e.code = 0; let r = ret as string; callback(e, r); - }).catch((e: BusinessError): void => { - callback(e, ""); + }).catch((e: Error): void => { + callback(e as BusinessError, ""); }); } @@ -797,8 +797,8 @@ function listFile(path: string, options?: ListFileOptions): Promise { promise.then((ret: NullishType): void => { let r = ret as string[]; resolve(r); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -812,8 +812,8 @@ function listFile(path: string, callback: AsyncCallback): void { e.code = 0; let r = ret as string[]; callback(e, r); - }).catch((e: BusinessError): void => { - callback(e, []); + }).catch((e: Error): void => { + callback(e as BusinessError, []); }); } @@ -826,8 +826,8 @@ function listFile(path: string, options: ListFileOptions, callback: AsyncCallbac e.code = 0; let r = ret as string[]; callback(e, r); - }).catch((e: BusinessError): void => { - callback(e, []); + }).catch((e: Error): void => { + callback(e as BusinessError, []); }); } @@ -851,8 +851,8 @@ function stat(file: string | number): Promise { promise.then((ret: NullishType): void => { let r = ret as Stat; resolve(r); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -866,8 +866,8 @@ function stat(file: string | number, callback: AsyncCallback): void e.code = 0; let r = ret as Stat; callback(e, r); - }).catch((e: BusinessError): void => { - callback(e, new StatInner(0)); + }).catch((e: Error): void => { + callback(e as BusinessError, new StatInner(0)); }); } @@ -882,8 +882,8 @@ function fsync(fd: number): Promise { }, fd); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -896,8 +896,8 @@ function fsync(fd: number, callback: AsyncCallback): void { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -913,8 +913,8 @@ function symlink(target: string, srcPath: string): Promise { }, target, srcPath); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -929,8 +929,8 @@ function rename(oldPath: string, newPath: string): Promise { }, oldPath, newPath); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -943,8 +943,8 @@ function rename(oldPath: string, newPath: string, callback: AsyncCallback) let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -964,8 +964,8 @@ function createRandomAccessFile(file: string | File, mode?: number, promise.then((ret: NullishType): void => { let raffile = ret as RandomAccessFileInner; resolve(raffile); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -978,8 +978,8 @@ function fdopenStream(fd: number, mode: string): Promise { promise.then((ret: NullishType): void => { let stream = ret as Stream; resolve(stream); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -994,7 +994,7 @@ function setxattr(path: string, key: string, value: string): Promise { FileIoImpl.setxattrSync(path, key, value), path, key, value); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { + }).catch((e: Error): void => { reject(e as BusinessError); }); }); @@ -1009,9 +1009,9 @@ function createRandomAccessFile(file: string | File, callback: AsyncCallback { + }).catch((e: Error): void => { let f: RandomAccessFile = new RandomAccessFileInner(0); - callback(e, f); + callback(e as BusinessError, f); }); } @@ -1025,9 +1025,9 @@ function createRandomAccessFile(file: string | File, mode: number, e.code = 0; let raffile = ret as RandomAccessFile; callback(e, raffile); - }).catch((e: BusinessError): void => { + }).catch((e: Error): void => { let f: RandomAccessFile = new RandomAccessFileInner(0); - callback(e, f); + callback(e as BusinessError, f); }); } @@ -1040,9 +1040,9 @@ function fdopenStream(fd: number, mode: string, callback: AsyncCallback) e.code = 0; let stream = ret as Stream; callback(e, stream); - }).catch((e: BusinessError): void => { + }).catch((e: Error): void => { let r: Stream = new StreamInner(0); - callback(e, r); + callback(e as BusinessError, r); }); } @@ -1058,8 +1058,8 @@ function createStream(path: string, mode: string): Promise { promise.then((ret: NullishType): void => { let stream = ret as Stream; resolve(stream); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1073,9 +1073,9 @@ function createStream(path: string, mode: string, callback: AsyncCallback { + }).catch((e: Error): void => { let r: Stream = new StreamInner(0); - callback(e, r); + callback(e as BusinessError, r); }); } @@ -1103,8 +1103,8 @@ function symlink(target: string, srcPath: string, callback: AsyncCallback) let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1130,8 +1130,8 @@ function lstat(path: string): Promise { let r = ret as Stat; resolve(r); } - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1151,8 +1151,8 @@ function lstat(path: string, callback: AsyncCallback): void { let r = ret as Stat; callback(e, r); } - }).catch((e: BusinessError): void => { - callback(e, new StatInner(0)); + }).catch((e: Error): void => { + callback(e as BusinessError, new StatInner(0)); }); } function copyFile(src: string | number, dest: string | number, mode?: number): Promise { @@ -1161,8 +1161,8 @@ function copyFile(src: string | number, dest: string | number, mode?: number): P FileIoImpl.copyFileSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1173,8 +1173,8 @@ function copy(srcUri: string, destUri: string, options?: CopyOptions): Promise { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1186,8 +1186,8 @@ function copyFile(src: string | number, dest: string | number, mode: number, cal let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1198,8 +1198,8 @@ function copy(srcUri: string, destUri: string, options: CopyOptions, callback: A let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1210,8 +1210,8 @@ function copyFile(src: string | number, dest: string | number, callback: AsyncCa let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1222,8 +1222,8 @@ function copy(srcUri: string, destUri: string, callback: AsyncCallback): v let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1331,7 +1331,7 @@ export class RandomAccessFileInner implements RandomAccessFile { } native setFilePointer0(filePointer: number): void; - + native close(): void; writeSync(buffer: ArrayBuffer | string, options?: WriteOptions): number { @@ -1350,8 +1350,8 @@ export class RandomAccessFileInner implements RandomAccessFile { promise.then((ret: NullishType): void => { let result = ret as number resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1365,8 +1365,8 @@ export class RandomAccessFileInner implements RandomAccessFile { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -1379,8 +1379,8 @@ export class RandomAccessFileInner implements RandomAccessFile { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -1400,8 +1400,8 @@ export class RandomAccessFileInner implements RandomAccessFile { promise.then((ret: NullishType): void => { let result = ret as number; resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1415,8 +1415,8 @@ export class RandomAccessFileInner implements RandomAccessFile { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -1429,8 +1429,8 @@ export class RandomAccessFileInner implements RandomAccessFile { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -1474,8 +1474,8 @@ export class FileInner implements File { }, exclusive); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1488,8 +1488,8 @@ export class FileInner implements File { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1501,8 +1501,8 @@ export class FileInner implements File { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1590,7 +1590,7 @@ export class StatInner implements Stat { this.nativeStat = stat; } } - + native isBlockDevice(): boolean; native isCharacterDevice(): boolean; native isDirectory(): boolean; @@ -1632,8 +1632,8 @@ export class StreamInner implements Stream { let promise = taskpool.execute((): undefined => this.closeSync()); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1644,8 +1644,8 @@ export class StreamInner implements Stream { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1656,8 +1656,8 @@ export class StreamInner implements Stream { let promise = taskpool.execute((): undefined => this.flushSync()); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1668,8 +1668,8 @@ export class StreamInner implements Stream { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -1683,8 +1683,8 @@ export class StreamInner implements Stream { promise.then((ret: NullishType): void => { let result = ret as number resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1698,8 +1698,8 @@ export class StreamInner implements Stream { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -1712,8 +1712,8 @@ export class StreamInner implements Stream { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -1727,8 +1727,8 @@ export class StreamInner implements Stream { promise.then((ret: NullishType): void => { let result = ret as number resolve(result); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -1742,8 +1742,8 @@ export class StreamInner implements Stream { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } @@ -1756,11 +1756,11 @@ export class StreamInner implements Stream { e.code = 0; let result = ret as number; callback(e, result); - }).catch((e: BusinessError): void => { - callback(e, 0); + }).catch((e: Error): void => { + callback(e as BusinessError, 0); }); } - + native readSync(buffer: ArrayBuffer, options?: ReadOptions): number; native seek(offset: number, whence?: number): number; } @@ -2119,15 +2119,15 @@ export class FileIoImpl { static native createStreamSync(path: string, mode: string): fileIo.Stream; static native createWatcherSync(path: string, events: number, listener: WatchEventListener): fileIo.Watcher; - + static native fdopenStreamSync(fd: number, mode: string): fileIo.Stream; - + static native dup(fd: number): fileIo.File; static native listFileSync(path: string, options?: ListFileOptions): string[]; static native lstatSync(path: string): fileIo.Stat; - + static native lseekSync(fd: number, offset: number, whence?: fileIo.WhenceType): number; static native mkdirSync(path: string): void; @@ -2143,7 +2143,7 @@ export class FileIoImpl { static native openSync(path: String, mode?: number): fileIo.File; static native readlinesSync(filePath: string, options?: Options): fileIo.ReaderIterator; - + static native readSync(fd: number, buffer: ArrayBuffer, options?: ReadOptions): number; static native readTextSync(filePath: string, options?: ReadTextOptions): string; diff --git a/interfaces/kits/js/src/mod_hash/ani/ets/@ohos.file.hash.ets b/interfaces/kits/js/src/mod_hash/ani/ets/@ohos.file.hash.ets index 7b825ee14..ca2c7964e 100644 --- a/interfaces/kits/js/src/mod_hash/ani/ets/@ohos.file.hash.ets +++ b/interfaces/kits/js/src/mod_hash/ani/ets/@ohos.file.hash.ets @@ -23,8 +23,8 @@ export default namespace hash { promise.then((ret: NullishType): void => { let res = ret as string; resolve(res); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -36,8 +36,8 @@ export default namespace hash { e.code = 0; let res = ret as string; callback(e, res); - }).catch((e: BusinessError): void => { - callback(e, ""); + }).catch((e: Error): void => { + callback(e as BusinessError, ""); }); } diff --git a/interfaces/kits/js/src/mod_securitylabel/ani/ets/@ohos.file.securityLabel.ets b/interfaces/kits/js/src/mod_securitylabel/ani/ets/@ohos.file.securityLabel.ets index 06e659dc2..4f81cef3d 100644 --- a/interfaces/kits/js/src/mod_securitylabel/ani/ets/@ohos.file.securityLabel.ets +++ b/interfaces/kits/js/src/mod_securitylabel/ani/ets/@ohos.file.securityLabel.ets @@ -23,8 +23,8 @@ namespace securityLabel { let promise = taskpool.execute((path: string, type: DataLevel): void => SecurityLabelImpl.setSecurityLabelSync(path, type), path, type); promise.then((ret: NullishType): void => { resolve(undefined); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -35,8 +35,8 @@ namespace securityLabel { let e = new BusinessError(); e.code = 0; callback(e, undefined); - }).catch((e: BusinessError): void => { - callback(e, undefined); + }).catch((e: Error): void => { + callback(e as BusinessError, undefined); }); } @@ -50,8 +50,8 @@ namespace securityLabel { promise.then((ret: NullishType): void => { let r = ret as string; resolve(r); - }).catch((e: BusinessError): void => { - reject(e); + }).catch((e: Error): void => { + reject(e as BusinessError); }); }); } @@ -63,8 +63,8 @@ namespace securityLabel { e.code = 0; let r = ret as string; callback(e, r); - }).catch((e: BusinessError): void => { - callback(e, ""); + }).catch((e: Error): void => { + callback(e as BusinessError, ""); }); } -- Gitee