Type Error with Default Value in Schema Annotations
I get this type error when I add a default string value
export const StringWithDefault = S.String.annotations({
decodingFallback: () => E.succeed(""),
});
export const Patch = S.Struct({
name: S.String,
description: StringWithDefault,
rarity: _Rarity,
marketHashName: S.propertySignature(StringWithDefault).pipe(
S.fromKey("market_hash_name"),
),
}).pipe(transformRarity);// just changes rarity to string has nothing to do w/ the error
export type Patch = typeof Patch.Type;
export const Patches = S.Array(Patch);
not assignable to parameter of type 'Schema<readonly ({ readonly name: string; readonly description: string; readonly marketHashName: string; } & { readonly rarity: string; readonly color: string; })[], readonly ({ readonly name: string; readonly description: string; readonly marketHashName: string; } & { ...; })[], never>'.
Types of property 'Encoded' are incompatible.
Type 'readonly ({ readonly name: string; readonly description: string; readonly rarity: { readonly name: string; readonly color: string; }; readonly market_hash_name: string; } | null)[]' is not assignable to type 'readonly ({ readonly name: string; readonly description: string; readonly marketHashName: string; } & { readonly rarity: string; readonly color: string; })[]'.
Type '{ readonly name: string; readonly description: string; readonly rarity: { readonly name: string; readonly color: string; }; readonly market_hash_name: string; } | null' is not assignable to type '{ readonly name: string; readonly description: string; readonly marketHashName: string; } & { readonly rarity: string; readonly color: string; }'.
Type 'null' is not assignable to type '{ readonly name: string; readonly description: string; readonly marketHashName: string; } & { readonly rarity: string; readonly color: string; }'.
Type 'null' is not assignable to type '{ readonly name: string; readonly description: string; readonly marketHashName: string; }'.deno-ts(2345)export const StringWithDefault = S.String.annotations({
decodingFallback: () => E.succeed(""),
});
export const Patch = S.Struct({
name: S.String,
description: StringWithDefault,
rarity: _Rarity,
marketHashName: S.propertySignature(StringWithDefault).pipe(
S.fromKey("market_hash_name"),
),
}).pipe(transformRarity);// just changes rarity to string has nothing to do w/ the error
export type Patch = typeof Patch.Type;
export const Patches = S.Array(Patch);
not assignable to parameter of type 'Schema<readonly ({ readonly name: string; readonly description: string; readonly marketHashName: string; } & { readonly rarity: string; readonly color: string; })[], readonly ({ readonly name: string; readonly description: string; readonly marketHashName: string; } & { ...; })[], never>'.
Types of property 'Encoded' are incompatible.
Type 'readonly ({ readonly name: string; readonly description: string; readonly rarity: { readonly name: string; readonly color: string; }; readonly market_hash_name: string; } | null)[]' is not assignable to type 'readonly ({ readonly name: string; readonly description: string; readonly marketHashName: string; } & { readonly rarity: string; readonly color: string; })[]'.
Type '{ readonly name: string; readonly description: string; readonly rarity: { readonly name: string; readonly color: string; }; readonly market_hash_name: string; } | null' is not assignable to type '{ readonly name: string; readonly description: string; readonly marketHashName: string; } & { readonly rarity: string; readonly color: string; }'.
Type 'null' is not assignable to type '{ readonly name: string; readonly description: string; readonly marketHashName: string; } & { readonly rarity: string; readonly color: string; }'.
Type 'null' is not assignable to type '{ readonly name: string; readonly description: string; readonly marketHashName: string; }'.deno-ts(2345)