Open wesleyolis opened 5 years ago
Then also when doing the following manipulation by implemented a phantom type symbol that can be checked for to determine if returning record that defined the type manipulation results. which has a modifier property which is bit flags, which would then allow you to implemented optimized method for various structures to process it faster based number of permutations and templating. To gather with algebraic data types.
type mutate<T> = {
[K in keyof T] : {PT.Def: ModFlags.Type | ModFlags.Nullable | ModFlags.Optional | ModFlags.Readonly,
PT.Type : string | number | Date | | T[K][PT.Type]
PT.Nullable : true | null | T[K][PT.Nullable],
PT.Optional : true | undefined | T[K][PT.Optional]
PT.Readonly: true | readonly | T[K][PT.Readonly]
}
The other type would be the ability to ModFlags.ModType, which allow optimal passthought of information, if PT.Type was modified and Modifiers remained the same.
Basically when using [k in keyof] and mutating structures in ways that can be found at these repositories it becomes apparent that to simplify the learning cure it would be better if the type modifiers such as optional/required/undefined/readonly|null can be accessed and interrogated separately from the type and modifiers mashed together.. So one can focus on writing a routine that would iterate the type to be integorate for the architectural structure/shape if to call it that, which allow one to write super fast simple methods to recursively no the difference between Record<string,any>, Array, never, unknown. instead of having to do the following: T extends Record<string,any> | undefined | readonly | null ? then recuse, else step over.
The following type integogation operators.
Phantom types
Maybe just implement the concept of phantom symbols, that don't actually exists, were by optional/required, nullable, readonly, type can be access like : T[PT.Required] extends true ? .. T[PT.Nullable] extends true ? ... T[PT.Readonly] extends true ? ... T[PT.Type] extends true ? ... T[PT.Cusom] extends true ? ... // For passing other information that doesn't exist to validate typings. allow one to create the own phantom types, which information we will pass onto for downstream validation in some complex situations like Mongoose Update Statement validation which has 3 parts.
Work around Mongoose Update Statment
Work around Mongoose Types
https://github.com/Microsoft/TypeScript/issues/28699
Checklist
My suggestion meets these guidelines: