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
The last line produces an error "Property 'length' does not exist on type 'never'". This goes away if the early return is removed. It seems that narrows the type of found from null to never, but that seems inappropriate in this situation (and hard to work around without any casts).
π Expected behavior
I'd expect the exclamation point to be enough to make the code typecheck (as it did in previous versions).
The text was updated successfully, but these errors were encountered:
this goes away if the early return is removed. It seems that narrows the type of found from null to never, but that seems inappropriate in this situation (and hard to work around without any casts).
Due to this the type is always known as null, and never as string. So when you return TypeScript knows it's not null, but it can only ever be null, so it must be never.
A simple workaround is to avoid the inferrence of found to be null by using a type assertion:
Bug Report
π Search Terms
"4.3" never
π Version & Regression Information
The code typechecks in 4.2.3, but no longer does so in 4.3.2.
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The last line produces an error "Property 'length' does not exist on type 'never'". This goes away if the early return is removed. It seems that narrows the type of
found
fromnull
tonever
, but that seems inappropriate in this situation (and hard to work around withoutany
casts).π Expected behavior
I'd expect the exclamation point to be enough to make the code typecheck (as it did in previous versions).
The text was updated successfully, but these errors were encountered: