Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1ffda9f
Add the 'awaited' type operator
rbuckton Jan 4, 2020
a981148
Merge branch 'master' into awaitedType2
rbuckton Feb 17, 2020
e7174b1
Add script to manually add reviewers to a PR when GH 'Suggested Revie…
rbuckton Feb 17, 2020
65c7377
Fix lint error in review script
rbuckton Feb 24, 2020
7e57fed
Merge branch 'master' into awaitedType2
rbuckton Feb 28, 2020
8ccb983
Only defer generic awaited type for possible thenable
rbuckton Mar 2, 2020
7ea8940
Merge branch 'master' into awaitedType2
rbuckton Mar 2, 2020
624db27
Add variance-like behavior for awaited
rbuckton Mar 4, 2020
95d7316
Merge branch 'master' into awaitedType2
rbuckton Mar 10, 2020
d9ff357
Switch awaited type params to 'unreliable' variance
rbuckton Mar 10, 2020
a980ffa
fix typo in inferTypes
rbuckton Mar 11, 2020
eaff435
Merge branch 'master' into awaitedType2
rbuckton Mar 16, 2020
17d7981
LKG without syntax in lib
rbuckton Mar 16, 2020
53e0aaa
LKG with new syntax in lib
rbuckton Mar 16, 2020
3164a0c
Add 'strictAwaitedTypes' flag
rbuckton Mar 17, 2020
8a5ed7f
Merge branch 'master' into awaitedType2
rbuckton Mar 17, 2020
ec879a5
Treat strictAwaitedTypes as strict-mode flag
rbuckton Mar 17, 2020
76ae7c8
Rename TAll, remove duplicate definition of 'race'
rbuckton Mar 17, 2020
bc83e41
Apply suggestions from code review
rbuckton Mar 18, 2020
a9aa2fd
Merge branch 'master' into awaitedType2
rbuckton Mar 18, 2020
a005b9c
Fix inference priority
rbuckton Mar 19, 2020
8bbcefd
Update comment to isGenericAwaitableType
rbuckton Mar 19, 2020
04c3b6c
Add overloads for then/catch to Promise
rbuckton Mar 20, 2020
5abdee7
Add inference heuristic for T | PromiseLike<T> (for any PromiseLike)
rbuckton Mar 20, 2020
b9f29c7
Remove strictAwaitedTypes flag
rbuckton Mar 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into awaitedType2
  • Loading branch information
rbuckton committed Mar 2, 2020
commit 7ea8940b08d2d4ba4296d6da974bd08f2c30aa59
14 changes: 8 additions & 6 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30024,18 +30024,20 @@ namespace ts {

/**
* Determines whether a type is a generic type whose base constraint could possibly resolve to a different
* type when awaited. A type is a generic "thenable" type when the type is a generic object type and
* any of the following conditions are met
* - The type has no base constraint.
* - OR The base constraint of the type is `any` or `unknown` or the empty object `{}`.
* - OR The base constraint has a callable `then` member.
* type when awaited. A type is a generic "thenable" type when all of the following conditions are met:
* - The type is a generic object type,
* - AND one of the following conditions are met
* - The type has no base constraint,
* - OR The base constraint of the type is `any`, `unknown`, `object`, or the empty object `{}`,
* - OR The base constraint has a callable `then` member.
*/
function isGenericAwaitableType(type: Type): boolean {
if (isGenericObjectType(type)) {
const baseConstraint = getBaseConstraintOfType(type);
return !baseConstraint ||
!!(baseConstraint.flags & (TypeFlags.AnyOrUnknown)) ||
!!(baseConstraint.flags & (TypeFlags.AnyOrUnknown | TypeFlags.NonPrimitive)) ||
baseConstraint === emptyObjectType ||
baseConstraint === emptyGenericType ||
isThenableType(baseConstraint);
}
return false;
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.