Open wesleyolis opened 5 years ago
Basically evaluate the the type in a narrowing fashion, which is less intensive than generating all the permutations. A technic I call tail recursive validation, but however has limitation that ...args : A[] can be in function <A extends Validate<T, A>>(...args : A[]). Current using overloads see https://github.com/wesleyolis/mongooseRelationalTypes/blob/master/src/mongooseUpdateStatment.ts
When working with types and one wants to capture generic typescript types and runtime information in one go, without using experimental decorators, which also has limitations when its comes to type categorization upfront, as it would require extract routines to evaluate if interface uses valid types subset of types when the interface is defined.
One doesn't want to evaluate at the level of string literals here, but at the level of primitive types.
What I would like to propose is a new key call it equal, which would check that the type equals or maybe implements, which perform the same logic as extends, but would not evaluate string | boolean primitives at literal level or deconstructed level of that type, basically stop there. Almost like named typing in a way.
Search Terms
generic type implements instead of extends generic implements
Suggestion
// This depends on who you read this statement, T equals boolean or string explicity // T implements boolean | string pars
Extract routine for ensuring decorators class for type mixing , conform to specific set of constraints
This method, however, like all others for nested records and arrays, makes it a whole lot more complicate to evaluate the typings. I am actually think of proposing a symbol type, which has identifiers, for structure, which allows simpler ability to iterator nested record structures..
Checklist
My suggestion meets these guidelines: