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 microsoft#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
@@ -3945,10 +3945,11 @@ namespace ts {
3945
3945
HomomorphicMappedType=1<<1,// Reverse inference for homomorphic mapped type
3946
3946
MappedTypeConstraint=1<<2,// Reverse inference for mapped type
3947
3947
ReturnType=1<<3,// Inference made from return type of generic function
3948
-
NoConstraints=1<<4,// Don't infer from constraints of instantiable types
3949
-
AlwaysStrict=1<<5,// Always use strict rules for contravariant inferences
3948
+
LiteralKeyof=1<<4,// Inference made from a string literal to a keyof T
3949
+
NoConstraints=1<<5,// Don't infer from constraints of instantiable types
3950
+
AlwaysStrict=1<<6,// Always use strict rules for contravariant inferences
3950
3951
3951
-
PriorityImpliesUnion=ReturnType|MappedTypeConstraint,// These priorities imply that the resulting type should be a union of all candidates
3952
+
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