Closed
Description
Add promised
type (continued)
- Never had a name for this.
await
?awaited
?- Positive sentiment for both.
- How bad is the world without this?
- Well stricter generic checks broke a lot of checking.
- But are things fixed now? We've gotten this far without it.
- Would love to see specifically why we need to do this.
- PR has some examples.
- At the end of the last meeting we had two open issues:
- Naming
- Highed order relationships.
- What if we just worked on some of the inference issues that
Promise
/PromiseLike
s experience relating to union type inference?- [Follow up with @rbuckton]
String enums and indexing
-
Now that string-enums are a thing, people want to use them everywhere, like in
- interface/literal types.
- computed properties
-
Would need to generalize declarations constructed with literal types:
const b = "b"; const x = { [b]: 100, } // equivalent to const y = { b: 100, }
-
What would we do in the case of
declare const x: "a" | "b"; const a = { [x]: 100, }
-
Is that
// { a: number } | { b: number } // or // { a?: number, b?: number } // or // { [x: string]: number }
-
-
Leaning towards last option for practicality.
-
What about cases where you want to quickly manufacture distinct cases?
function createThing<K extends "a" | "b", payload: T>(kind: K, payload: T) { return { kind, payload: { [kind]: T, } }; } createThing("a", 100);