-
-
Notifications
You must be signed in to change notification settings - Fork 191
Description
Will totally remake Metadata type.
The reason why remaking the Metadata type is to enhancing the type tag feature. Current typia's type tag is allowed in specific types; boolean, number, string and Array. However, after remaking the Metadata type, every type can take advantage of the typia tag.
To make it come true, Metadata will not be no more class type, but would be changed to an union type of interface types. It would be similar like JSON schema types like OpenApi.IJsonSchema or IClaudeSchema, but would be much complicate than them.
Here is my blueprint of the next version's Metadata type.
export type Metadata =
// atomic types
| Metadata.IConst
| Metadata.IBoolean
| Metadata.INumber
| Metadata.IString
| Metadata.ITemplate
// instances
| Metadata.IObject
| Metadata.IArray
| Metadata.ITuple
| Metadata.INative
| Metadata.IFunction
// special types
| Metadata.ITag
| Metadata.IReference
| Metadata.IUnion
| Metadata.IIntersection;The first type tag supported in the next version by entirely remaking the Metadata type is: tags.Description<string>.
It can specify the TypeGuardError.description and IValidation.IError.description properties when type error occurs. This tags.Description<string> would be useful when you're developing an AI function calling schema for the type validation feedback reason.
Also, break change on Metadatea type will make typia to fully support the object literal expression type.
When user of typia does not declare an independent type or interface, but hard-code an object type as an literal expression, typia has labeled the type name as __type.o1 and Array<__type>.o6. It is because typia has forcibly labeled such no-named types due to the Metadata has not considered such hard-coded object literal expression type.
typia.createAssert<{
id: string;
name: string;
age: number;
}>(); // have not considered hard-coded
// object literal expression type
typia.createAssert<IMember>(); // considered
interface IMember {
id: string;
name: string;
age: number;
}