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
More specific inference for constrained 'infer' types in template literal types (#48094)
* More specific inference for constrained 'infer' types in template literal types
* PR feedback
* Add inference priority for template type placeholders
* Infer to a preferred constraint instead of a union
* Add reduceType
* Switch tests to use infer..extends
* Add missing primitive constraint cases
* Update .types tests
* Remove TemplateTypePlaceholderPriority
* Remove reduceType
function isValidBigIntString(s: string): boolean {
22115
+
/**
22116
+
* Tests whether the provided string can be parsed as a number.
22117
+
* @param s The string to test.
22118
+
* @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
22119
+
*/
22120
+
function isValidNumberString(s: string, roundTripOnly: boolean): boolean {
22121
+
if (s === "") return false;
22122
+
const n = +s;
22123
+
return isFinite(n) && (!roundTripOnly || "" + n === s);
22124
+
}
22125
+
22126
+
/**
22127
+
* @param text a valid bigint string excluding a trailing `n`, but including a possible prefix `-`. Use `isValidBigIntString(text, roundTripOnly)` before calling this function.
Copy file name to clipboardexpand all lines: src/compiler/types.ts
+1-1
Original file line number
Diff line number
Diff line change
@@ -5877,7 +5877,7 @@ namespace ts {
5877
5877
AlwaysStrict=1<<10,// Always use strict rules for contravariant inferences
5878
5878
MaxValue=1<<11,// Seed for inference priority tracking
5879
5879
5880
-
PriorityImpliesCombination=ReturnType|MappedTypeConstraint|LiteralKeyof,// These priorities imply that the resulting type should be a combination of all candidates
5880
+
PriorityImpliesCombination=ReturnType|MappedTypeConstraint|LiteralKeyof,// These priorities imply that the resulting type should be a combination of all candidates
5881
5881
Circularity=-1,// Inference circularity (value less than all other priorities)
0 commit comments