declare namespace nasl.error { type ErrorTypeKind = string; /** * 内部使用的基础错误类型 * @internal */ export class BaseError { readonly errorType: T & nasl.core.String; errorMsg: nasl.core.String; } export type Error = nasl.ui.Error; // 其他类型动态注入 export namespace util { type ErrorStructureShape = { errorType: ErrorTypeKind; errorMsg: nasl.core.String }; type IsStringLiteral = string extends T ? false : true; export type ExcludeErrors = T extends (...args: any[]) => any ? (...args: Parameters) => ExcludeErrorsHelper> : ExcludeErrorsHelper; type ExcludeErrorsHelper = T extends ErrorStructureShape ? never : T extends nasl.error.Error ? never : T; export function excludeErrors(value: T): ExcludeErrors; export function excludeErrorsInTupleHead( value: T ): // 泛型函数可能为 () => [返回值类型, ...剩余未填写的泛型参数(若有)] // 去除"返回值类型"中的Error,其余不变 T extends [infer Head, ...infer Tail] ? [ExcludeErrorsHelper, ...Tail] : T; type A = ExcludeErrors< { errorType: nasl.core.String; errorMsg: nasl.core.String } | nasl.error.Error >; } }