-
When I give the type PersonnelRole =
| string
| {
type: 'contractor';
contractStartDate: string;
contractEndDate: string;
}; The resulting type on the entity is reduces to the primitive type I checked the implementation of declare function CustomAttributeType<T>(
base: T extends string ? 'string'
: T extends number ? 'number'
: T extends boolean ? 'boolean'
: 'any'
): T extends string | number | boolean
? OpaquePrimitiveTypeName<T>
: CustomAttributeTypeName<T>; Is there a specific reason for this or could it be changed to handle union types? |
Beta Was this translation helpful? Give feedback.
Answered by
tywalch
Oct 17, 2023
Replies: 1 comment 1 reply
-
Hi @zirkelc 👋 This is a necessity simply because of how TypeScript widens types. You can definitely roll your own option here to avoid the trappings of your union with |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
zirkelc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @zirkelc 👋
This is a necessity simply because of how TypeScript widens types. You can definitely roll your own option here to avoid the trappings of your union with
string
:https://electrodb.fun/?#code/PQKgBAsg9gJgpgGzARwK5wE4Es4GcA0YuccYGeqCALgUQBYCG5YA7llXWAGbZwB2MXGBDAAUKKwBbAA5QMVMAG8wAUT5V2AT0IBlTADcsAYziEAwqlxUokgIJUq2AEaoqcACqbpcAHINJpAC+3Bg2YABEiHBGjrBO4QDc4kZQfFZgVAxOCKQAvBGaUKgYAPqZ2XAlfP5wieJUXqQACpi4qXyIAEpQOWD5ogA+RI5YfADmg0qiYDMZjQBcYADkKeoYDDFyS0mzYKuOG1Q6mfIAIgxui1bY4zuz++sxajDnl8M3Y0mBSaKr6d4YNp8DoIbo5TzePoRBh8TThMAMISoPgAaz4UBYfARQgsVhs9hGLjcEN8NQAPC1Ae0uj04AA+H6gMDuREooRqDQNYRiP4KNz+CBwSROVpQjosVTqLQACmmU12klgiEWijlu34nM0i3CmVwbPC+DVs30rSwqW1AEYDUaZsQMIYTNrdSiGNJpOEj…