hi! i've noticed it has become quite annoying to do .Value for each of the union types & .VALUE for all the enums i'm trying to use. i'm wondering if the team here has considered using a type with the same name as the above constructs instead to declare their types. for example:
+ declare type Asset = Image | Precomposition | Sound | DataSource;
declare namespace Asset {
// ...
- type Value = Image | Precomposition | Sound | DataSource;
}
let asset: Asset;
// ^ this is the union type, equivalent to `Asset.Value`
let sound: Asset.Sound;
// ^ ^
// | | this is the type inside of the namespace, unchanged
// | this is the namespace, unchanged
or in the case of enums, either using the enum as a top-level export, which does this duality automatically:
+ declare enum Composite {
+ ABOVE = 1,
+ BELOW = 2,
+ }
- declare namespace Composite {
- type Value = Above | Below;
- type Above = 1;
- type Below = 2;
- const enum VALUE {
- ABOVE = 1,
- BELOW = 2,
- }
- }
let composite: Composite;
// ^ this is the union type of all the values in the enum, equivalent to `Composite.Value`
let above: Composite.ABOVE = Composite.ABOVE;
// ^ ^
// | | this is the property value, equivalent to `Composite.VALUE.ABOVE`
// | this is the property type, equivalent to `Composite.Above`
in my opinion this would greatly improve the DX & help reduce confusion & noise in consumers' code.
related: #15
thanks for your consideration in advanced!
hi! i've noticed it has become quite annoying to do
.Valuefor each of the union types &.VALUEfor all the enums i'm trying to use. i'm wondering if the team here has considered using atypewith the same name as the above constructs instead to declare their types. for example:or in the case of enums, either using the
enumas a top-level export, which does this duality automatically:in my opinion this would greatly improve the DX & help reduce confusion & noise in consumers' code.
related: #15
thanks for your consideration in advanced!