You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Combine keyof T inferences
* Extract covariant inference derivation into function
* Test:keyof inference lower priority than return inference
for #22376
* Update 'expected' comment in keyofInferenceLowerPriorityThanReturn
* Update comment in test too, not just baselines
* Fix typo
* Move tests
Copy file name to clipboardExpand all lines: src/compiler/types.ts
+4-3
Original file line number
Diff line number
Diff line change
@@ -3920,10 +3920,11 @@ namespace ts {
3920
3920
HomomorphicMappedType=1<<1,// Reverse inference for homomorphic mapped type
3921
3921
MappedTypeConstraint=1<<2,// Reverse inference for mapped type
3922
3922
ReturnType=1<<3,// Inference made from return type of generic function
3923
-
NoConstraints=1<<4,// Don't infer from constraints of instantiable types
3924
-
AlwaysStrict=1<<5,// Always use strict rules for contravariant inferences
3923
+
LiteralKeyof=1<<4,// Inference made from a string literal to a keyof T
3924
+
NoConstraints=1<<5,// Don't infer from constraints of instantiable types
3925
+
AlwaysStrict=1<<6,// Always use strict rules for contravariant inferences
3925
3926
3926
-
PriorityImpliesUnion=ReturnType|MappedTypeConstraint,// These priorities imply that the resulting type should be a union of all candidates
3927
+
PriorityImpliesCombination=ReturnType|MappedTypeConstraint|LiteralKeyof,// These priorities imply that the resulting type should be a combination of all candidates
insertOnConflictDoNothing(bookTable,ConflictTarget.tableColumns(["serial"]));// <-- No error here; should use the type inferred for the return type of `tableColumns`
47
+
}
48
+
49
+
50
+
//// [keyofInferenceLowerPriorityThanReturn.js]
51
+
var bookTable = null;
52
+
function insertOnConflictDoNothing(_table, _conflictTarget) {
53
+
thrownewError();
54
+
}
55
+
function f() {
56
+
insertOnConflictDoNothing(bookTable,ConflictTarget.tableColumns(["serial"]));// <-- No error here; should use the type inferred for the return type of `tableColumns`
0 commit comments