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
Have a PR that allows some return expressions to be assignable to a conditional type.
The idea of the change: instead of seeing if the return expression is assignable, we look for if the tested type parameter is used uniquely by a parameter, and instantiate the return type with the narrowed type of the parameter.
Most perf doesn't regress from this currently - because nobody is able to use this pattern.
Constructed test file seems to do well where
Want to get a sense of if we should continue with this concept.
Really need to understand what the plan of implementation is. Like the idea at a high level.
The text was updated successfully, but these errors were encountered:
Linting Against Unused Locals and Variables
#57123
noUnusedLocals
/noUnusedParameters
.@see
,@link
in TypeScript and relying on import elision.@type
in JavaScript files.import(...)
types, call it a day.5.4 Breaking Changes
#57117
Indexing with Intersections of String Literals and String Mapping Types Applied to Non-Generic Strings
Inconsistent intersections of string literal types and pattern string mapping types #57192
[NewErrors] 5.4.0-dev.20240121 vs 5.3.3 #57117 (comment)
Breaks lead to finding that
"foo" & Lowercase<string>
is not recognized when indexing into{ "foo": SomeType }
{ "foo": SomeType }["foo" & Lowercase<string>]
We have a fix, we would like to try it out for 5.4 to reduce noise from breakage.
Need to make sure it doesn't break more!
Narrowing Conditional
[NewErrors] 5.4.0-dev.20240121 vs 5.3.3 #57117 (comment)
[NewErrors] 5.4.0-dev.20240121 vs 5.3.3 #57117 (comment)
T
has a constraint ofRecord<string, any>
, which any object type can be assigned to.Previously,
DefaultValues
would fall into the true branch when trying to narrow against the constraint.Now, TypeScript acknowledges that
T
could possibly be either branch of the conditional type, and so narrowing doesn'tIntersection Reduction
Reduce intersections of constrained type variables and primitive types #56515
Move
Equals
constraint into an intersection type. reduxjs/react-redux#2123Sent a PR upstream, fixed things.
Didn't work in one case, but seems like you can fix it by replacing an
any
with anunknown
.Aside, we feel weird about using these hacks to enforce that types are exact in parameters, rather than subtypes of each other.
equals<T, U>(x: T & NoInfer<U>, y: U & NoInfer<T>)
and that works.Breaks on Vue
Add auto-import for the
package.json
imports
field #55015Add auto-import for the
package.json
imports
field #55015Resolution issue has been fixed.
The other break is annoying but sort of expected - the code either needs a type assertion or to be honest about the return type.
Implementing Functions that Return Conditional Types
#33014
The text was updated successfully, but these errors were encountered: