mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 18:29:23 +02:00
refactor(struct): rename member types
This commit is contained in:
parent
90dcbad660
commit
5a18c845c2
13 changed files with 85 additions and 85 deletions
|
@ -28,9 +28,9 @@ type AddFieldDescriptor<
|
|||
Identity<Struct<
|
||||
// Merge two types
|
||||
// Evaluate immediately to optimize editor hover tooltip
|
||||
Evaluate<TFields & Record<TFieldName, TDefinition['valueType']>>,
|
||||
Evaluate<TFields & Record<TFieldName, TDefinition['TValue']>>,
|
||||
// Merge two `TOmitInitKey`s
|
||||
TOmitInitKey | TDefinition['omitInitKeyType'],
|
||||
TOmitInitKey | TDefinition['TOmitInitKey'],
|
||||
TExtra,
|
||||
TPostDeserialized
|
||||
>>;
|
||||
|
@ -56,7 +56,7 @@ interface ArrayBufferLikeFieldCreator<
|
|||
<
|
||||
TName extends PropertyKey,
|
||||
TType extends ArrayBufferLikeFieldType,
|
||||
TTypeScriptType = TType['valueType'],
|
||||
TTypeScriptType = TType['TTypeScriptType'],
|
||||
>(
|
||||
name: TName,
|
||||
type: TType,
|
||||
|
@ -81,7 +81,7 @@ interface ArrayBufferLikeFieldCreator<
|
|||
TName extends PropertyKey,
|
||||
TType extends ArrayBufferLikeFieldType,
|
||||
TOptions extends VariableLengthArrayBufferLikeFieldOptions<TFields>,
|
||||
TTypeScriptType = TType['valueType'],
|
||||
TTypeScriptType = TType['TTypeScriptType'],
|
||||
>(
|
||||
name: TName,
|
||||
type: TType,
|
||||
|
@ -112,7 +112,7 @@ interface ArrayBufferTypeFieldDefinitionCreator<
|
|||
> {
|
||||
<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = TType['valueType'],
|
||||
TTypeScriptType = TType['TTypeScriptType'],
|
||||
>(
|
||||
name: TName,
|
||||
options: FixedLengthArrayBufferLikeFieldOptions,
|
||||
|
@ -133,7 +133,7 @@ interface ArrayBufferTypeFieldDefinitionCreator<
|
|||
TName extends PropertyKey,
|
||||
TLengthField extends LengthField<TFields>,
|
||||
TOptions extends VariableLengthArrayBufferLikeFieldOptions<TFields, TLengthField>,
|
||||
TTypeScriptType = TType['valueType'],
|
||||
TTypeScriptType = TType['TTypeScriptType'],
|
||||
>(
|
||||
name: TName,
|
||||
options: TOptions,
|
||||
|
@ -154,7 +154,7 @@ interface ArrayBufferTypeFieldDefinitionCreator<
|
|||
export type StructPostDeserialized<TFields, TPostDeserialized> =
|
||||
(this: TFields, object: TFields) => TPostDeserialized;
|
||||
|
||||
export type StructDeserializedType<TFields extends object, TExtra extends object, TPostDeserialized> =
|
||||
export type StructDeserializedResult<TFields extends object, TExtra extends object, TPostDeserialized> =
|
||||
TPostDeserialized extends undefined ? Overwrite<TExtra, TFields> : TPostDeserialized;
|
||||
|
||||
export class Struct<
|
||||
|
@ -162,16 +162,16 @@ export class Struct<
|
|||
TOmitInitKey extends PropertyKey = never,
|
||||
TExtra extends object = {},
|
||||
TPostDeserialized = undefined,
|
||||
> implements StructLike<StructDeserializedType<TFields, TExtra, TPostDeserialized>>{
|
||||
public readonly fieldsType!: TFields;
|
||||
> implements StructLike<StructDeserializedResult<TFields, TExtra, TPostDeserialized>>{
|
||||
public readonly TFields!: TFields;
|
||||
|
||||
public readonly omitInitType!: TOmitInitKey;
|
||||
public readonly TOmitInitKey!: TOmitInitKey;
|
||||
|
||||
public readonly extraType!: TExtra;
|
||||
public readonly TExtra!: TExtra;
|
||||
|
||||
public readonly initType!: Evaluate<Omit<TFields, TOmitInitKey>>;
|
||||
public readonly TInit!: Evaluate<Omit<TFields, TOmitInitKey>>;
|
||||
|
||||
public readonly deserializedType!: StructDeserializedType<TFields, TExtra, TPostDeserialized>;
|
||||
public readonly TDeserializeResult!: StructDeserializedResult<TFields, TExtra, TPostDeserialized>;
|
||||
|
||||
public readonly options: Readonly<StructOptions>;
|
||||
|
||||
|
@ -229,9 +229,9 @@ export class Struct<
|
|||
public fields<TOther extends Struct<any, any, any, any>>(
|
||||
other: TOther
|
||||
): Struct<
|
||||
TFields & TOther['fieldsType'],
|
||||
TOmitInitKey | TOther['omitInitType'],
|
||||
TExtra & TOther['extraType'],
|
||||
TFields & TOther['TFields'],
|
||||
TOmitInitKey | TOther['TOmitInitKey'],
|
||||
TExtra & TOther['TExtra'],
|
||||
TPostDeserialized
|
||||
> {
|
||||
for (const field of other._fields) {
|
||||
|
@ -245,7 +245,7 @@ export class Struct<
|
|||
private number<
|
||||
TName extends PropertyKey,
|
||||
TType extends NumberFieldType = NumberFieldType,
|
||||
TTypeScriptType = TType['valueType']
|
||||
TTypeScriptType = TType['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
type: TType,
|
||||
|
@ -262,7 +262,7 @@ export class Struct<
|
|||
*/
|
||||
public int8<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint8']['valueType']
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint8']['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
_typescriptType?: TTypeScriptType,
|
||||
|
@ -279,7 +279,7 @@ export class Struct<
|
|||
*/
|
||||
public uint8<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint8']['valueType']
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint8']['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
_typescriptType?: TTypeScriptType,
|
||||
|
@ -296,7 +296,7 @@ export class Struct<
|
|||
*/
|
||||
public int16<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint16']['valueType']
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint16']['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
_typescriptType?: TTypeScriptType,
|
||||
|
@ -313,7 +313,7 @@ export class Struct<
|
|||
*/
|
||||
public uint16<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint16']['valueType']
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint16']['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
_typescriptType?: TTypeScriptType,
|
||||
|
@ -330,7 +330,7 @@ export class Struct<
|
|||
*/
|
||||
public int32<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = (typeof NumberFieldType)['Int32']['valueType']
|
||||
TTypeScriptType = (typeof NumberFieldType)['Int32']['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
_typescriptType?: TTypeScriptType,
|
||||
|
@ -347,7 +347,7 @@ export class Struct<
|
|||
*/
|
||||
public uint32<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint32']['valueType']
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint32']['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
typescriptType?: TTypeScriptType,
|
||||
|
@ -366,7 +366,7 @@ export class Struct<
|
|||
*/
|
||||
public int64<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = (typeof NumberFieldType)['Int64']['valueType']
|
||||
TTypeScriptType = (typeof NumberFieldType)['Int64']['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
_typescriptType?: TTypeScriptType,
|
||||
|
@ -385,7 +385,7 @@ export class Struct<
|
|||
*/
|
||||
public uint64<
|
||||
TName extends PropertyKey,
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint64']['valueType']
|
||||
TTypeScriptType = (typeof NumberFieldType)['Uint64']['TTypeScriptType']
|
||||
>(
|
||||
name: TName,
|
||||
_typescriptType?: TTypeScriptType,
|
||||
|
@ -524,7 +524,7 @@ export class Struct<
|
|||
|
||||
public async deserialize(
|
||||
context: StructDeserializationContext
|
||||
): Promise<StructDeserializedType<TFields, TExtra, TPostDeserialized>> {
|
||||
): Promise<StructDeserializedResult<TFields, TExtra, TPostDeserialized>> {
|
||||
const value = new StructValue();
|
||||
Object.defineProperties(value.value, this._extra);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue