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
{{ message }}
Repository navigation
Error for explicit return type with no return statements is misleading #53559
Fixed by PR #53607. In 5.1.0-dev.20230401, (): unknown => {} was accepted while TS2355 said only void and any could omit a return. Starting with 5.1.0-dev.20230402, both the string and unknown forms report TS2355, whose text correctly includes undefined, void, and any. The same result is present in TypeScript 6.0.3 and the current native compiler.
Activity
fatcerberus commentedon Mar 28, 2023
In fact can't you now annotate with any type which is inhabited by
undefined?DanielRosenwasser commentedon Mar 28, 2023
Pretty much, which means that if you wrote
that'll be okay in TypeScript 5.1. You'll need to enable
--noImplicitReturnsto catch something like that.RyanCavanaugh commentedon Sep 19, 2026
Fixed by PR #53607. In 5.1.0-dev.20230401,
(): unknown => {}was accepted while TS2355 said onlyvoidandanycould omit a return. Starting with 5.1.0-dev.20230402, both thestringandunknownforms report TS2355, whose text correctly includesundefined,void, andany. The same result is present in TypeScript 6.0.3 and the current native compiler.