fix: 类型

This commit is contained in:
unanmed 2024-03-02 19:27:57 +08:00
parent 5bf261b4a5
commit cb4b24106d
3 changed files with 12 additions and 12 deletions

View File

@ -578,6 +578,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
battle: function () {
// 这个插件负责战斗相关内容
// 注意,对于电脑作者,极度推荐使用 vscode 进行代码编写,可以享受到新版的类型标注
// 同时由于类型标注过于复杂样板编辑器无法部署因此样板编辑器也无法享受到新API的代码补全等
// 因此极度推荐使用 vscode 进行编写
// --------------- 战后脚本
// enemy: DamageEnemy实例也就是怪物本身
// x, y: 怪物坐标

View File

@ -644,8 +644,8 @@ export namespace Damage {
* @param hero
*/
export function calDamageWith(
info: EnemyInfo,
hero: Partial<HeroStatus>
info: DeepReadonly<EnemyInfo>,
hero: DeepReadonly<Partial<HeroStatus>>
): number | null {
return null;
}

16
src/types/util.d.ts vendored
View File

@ -820,31 +820,27 @@ type Save = DeepReadonly<{
time: number;
}>;
type ValueType = number | string | boolean | undefined | null | bigint | symbol;
/**
* 使
*/
type DeepReadonly<T> = {
readonly [P in keyof T]: T[P] extends number | string | boolean
? T[P]
: DeepReadonly<T[P]>;
readonly [P in keyof T]: T[P] extends ValueType ? T[P] : DeepReadonly<T[P]>;
};
/**
* 使
*/
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends number | string | boolean
? T[P]
: DeepPartial<T[P]>;
[P in keyof T]?: T[P] extends ValueType ? T[P] : DeepPartial<T[P]>;
};
/**
* 使
*/
type DeepRequired<T> = {
[P in keyof T]-?: T[P] extends number | string | boolean
? T[P]
: DeepRequired<T[P]>;
[P in keyof T]-?: T[P] extends ValueType ? T[P] : DeepRequired<T[P]>;
};
/**
@ -858,7 +854,7 @@ type Writable<T> = {
* 使
*/
type DeepWritable<T> = {
-readonly [P in keyof T]: T[P] extends number | string | boolean
-readonly [P in keyof T]: T[P] extends ValueType
? T[P]
: DeepWritable<T[P]>;
};