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
Seems like this could break behavior in the presence of what TypeScript falls back to in failed inferences.
Nope! We see if the inferred type is assignable to the constraint, and fall back to the constraint if not. Since we infer {} in the presence of no inferences and that's assignable to any, that's okay.
Need to unify the idea of mapped types and index signatures.
Maybe the idea here is that existing index signatures continue to work the way they do today, and any declarations of normal properties (i.e. using unions of literal types) don't have to apply.
Today, when we have to determine the type of a parameter, we ask
Is there an annotation?
Is there a contextual type?
Is there an initializer?
Can we build a type implied by the binding pattern?
When you have a contextual type, but that contextual type is a type parameter in inference, then you run into an awkward loop.
What we arguably should do is say that contextual typing fixes the type parameter, and if the type parameter isn't constrained then you get inference to {}.
What we instead to is say there's no contextual type, try to infer from the binding pattern, and then infer to the type parameter.
Turns out this has inconsistent experiences in the IDE.
This is a breaking change under noImplicitAny, but we need to make a call
Different treatment of methods, functions expressions, and arrow functions
Type parameters constrained to
any
#29571
any
.{}
in the presence of no inferences and that's assignable toany
, that's okay.Apply contextual types from inferred return types
#29478
const
contexts#29510
Seems like there was some confusion on naming, but looks reasonable.
Improved simplification and restrictive instantiation of conditionals
#29437
T extend U
always being true always imply thatT
subsumesT & U
anyway?Unioning issues on thousands of object literals
#28707
#28727
{}
.Negated types
#29317
Index signatures
#26797
How do you fall into this scenario?
"foo"
with typeT
de-sugars to[x: "foo"]: T
.Contextually typed parameters with binding patterns
#28816
{}
.noImplicitAny
, but we need to make a callDifferent treatment of methods, functions expressions, and arrow functions
#29520
T
this
parameter. The others do.this
.Invariant predicates
#26981
#27686
{}
toany
because usesisIdenticalTo
.The text was updated successfully, but these errors were encountered: