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
functionstring(value: unknown): asserts value is string{if(typeofvalue!="string"){thrownewTypeError(`Expected a string`)}}constworks=(source: unknown)=>{string(source)returnsource.toUpperCase()}constbreaks=(source: unknown)=>{console.log(string(source))returnsource.toUpperCase()}constalsobreaks=(source: unknown)=>[string(source),source.toUpperCase()]```### π Actual behaviorFunctions `break` and `alsobreak` do not type check and produce following error: "'source' is of type 'unknown'.", because type refinement produced by function "string" don't seem to apply, if asserting function is not a statement.### π Expected behaviorI would expect all three functions to type check, because `string` typerefinementshouldapplytoevenifrefinement is nestedinanexpression.
### AdditionalinformationabouttheissueProvidedexampleseemscontrivedbecauseitwasreducedtobareminimum,howevertherearelegitimateusesforrefinementsliketheabove[forexample](https://www.typescriptlang.org/play/?#code/MYGwhgzhAEBqYCcA8AVaBeaBXAdgaxwHsB3HAPmgG8AoaaAFwE8AHAUwC5ocsQQAfCPQQBLHAHNa0YIRyCEWYPUIIAFAEoqkuvQAWwiADombDFx4hJAX0kBbMPWA6VANzAgsHbPiKk1nV+6s0PrQaDR0dMIAZtAqxqyEMQEe0ACE6Ji6+kYsrBrhEdo6CCRcrMShuQCiCCWqAAbwgdAAJJTJrJbQACaErDBE9FIyUcIINgyEDLmtlFmG8Zb1alrQXawgEEEFhQis9FgIOAzyrKvWdNbW1PGhrOOoprgEJOSmaHxwiKhk1NSgkBgAEkcEMCoJ7MJgNA7A4nPR7jZOChEX5oID7vQYAjxsEYCiHtwbAAje4UHbBGJxXKJBiItIZaAAciJpIQTOgADJOdAAHJYEn3Az6EEIsT3OKo-KrCK6EoVHDlSpsGp1FRMqoADzYilY3XRZkF7JWhQua2o1wBUGgAAVCKIwZIIfQoTD7I4VBBCIdgJ5KNBNZx4MhWWSADTQRhB76hhAUSzSwoAeiT0AM6asFr+KegAEEoJiYMRlHh0cAStbnawbKxQRB-jJBAHTIqKsHqKKDLCPZqVnaHV33U5-ZqI1Hmwm-tQcwARPoDQhDYsIUuiaCsbV7KDCRsN2RDRgtpXt6SyQggVgGECEMQqSSd7tORhqMOSfugwdwlQjziMMe-tYVhWPcm1POQwAdGBMAAbXvD9HxUZ9Xzod96E-D0f0jf9I0A6gAF0-iiXBFB3Y5HAgnBPW9BBfU4Z4fBwRNoD2A4jikHQKKzEChgALyPNtEBA89L2vW8HyHFQeLUPt7XgiTMJ47C+ITIA) when composing set of constraints for later execution.
The text was updated successfully, but these errors were encountered:
π Search Terms
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABAZygJxmA5gCgG4CGANiAKYBci4A1mHAO5gCUlByypaUyihJpiGD1QZsiAN4AoRDMHBEOKAE8ADqTjy+ZRAEIAvIgBEIzFkNMJ02dagALNA0RhS9RABVVpAKJoHaHAAGXgAeatCkACaIBCjopgFMVjIAvpKpkhAIqIj0cGjUPAY4yHAgaBAUVGC0DMyIegB8ltYm2MWl5aSJ1mikUGVIJWUVAHRQcACqKmpoAMJspDiJ6Zlg2QBGvQQF9QpDnZQ0dIwWjc2yqyVEpCNEcLitDx0VTN2yvf1og88341Mz8w4SzSkgyWSg0SIJU2pG2hT2P0O1WOdTOAG0krFRE9hl0ADSY-ajP7TTiAxaJAC6QA
π» Code
The text was updated successfully, but these errors were encountered: