-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Description
Inference Heuristic for Promises
- Recently we "fixed" the
Promiseconstructor to leverage functionality where trailingvoidparameters could become optional. - However, this breaks a couple of cases - one big one where when promisifying functions.
- There are no inferences, so we go to
unknown, butunknownisn't an optional parameter type.
- There are no inferences, so we go to
- Idea: add special inference for the "revealing constructor" pattern.
-
new Yadda(callbackParam => { callbackParam(); });
- This is really based on
new Promise(resolve => { resolve(); });
- Figure out the type arguments for
Yaddabased on- invocations of
callbackParam - contextual type of use-sites of
callbackParam
- invocations of
-
- What's a use-site? Do you walk the whole tree?
- We use the text search logic from find-all-refs
- Unicode escapes?
- Conditional slower code path.
- No major errors in our test suites.
- This makes sense from a type perspective because [[equivalent to being an input position?]]
- Thought we added logic for making
unknownan optional parameter.- Only in JS files.
- Feels like this is something we'd do for JavaScript...but could we ever really spec this? Not a lot of generalization.
- There should be a more general approach.
- Circularities?
- Afraid of phantom bugs where quick info diverges from the actual type-checked type.
- Very similar to @sandersn's earlier work on investigating use-site inference.
- Very slow, but very naive implementation, used recursive reference-finding.
- How bad of a break are the current changes (without this PR)?
- A number of changes in VS Code
- Can move this code into a quick-fix to help people migrate.
- Might even be simpler.
- How does this affect
--strictmode?- Current behavior, this PR are invariant on strict modes.
- Does this break any weird stuff?
const x = new Promise(resolve => { resolve(); });
- Conclusion
- Not this change, nor a more general change, for 4.1
- Hear out the user feedback, see if we need to revert
Promise'sresolve's parameter's optionality.
Template Casing Operators
- People are not in love with the "magic modifiers"
- Already don't need
capitalizeanduncapitalizeas built-ins - can base them off of conditional types with inference anduppercase/lowercase.
- Already don't need
- Some way of denoting user-space types with type aliases instead of type operators.
type Yadda = internaltype Uppercase<T> = internal("uppercase");type Uppercase<T> = internal["uppercase"];
- Variance computation?
- We could still do that.
- Would we put constraints in the
.d.tsfile?- Does distributivity still work on this?
- What about powering the feature based on writing actual code with an object model?
- Not for 4.1.
- Still doesn't work on a locale-aware transform.
- Back to syntax bikeshedding syntax
intrinsic
- What are we merging today?
- Can't rip out the operators in time for beta.
- Can add the type aliases.
- Remove the operator in the RC
- Potentially error in the
.d.tsfile.
- Messaging to the community is use the type alias reference versions (i.e. use
Uppercaseinstead ofuppercase). - Will add some sort of
instrinsicmodifier on type aliases.
treybrisbane, Kingwl and tonivj5mihailik
Metadata
Metadata
Assignees
Labels
Design NotesNotes from our design meetingsNotes from our design meetings