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
isolatedDeclarations should not have warning for functions that have no return statementsΒ #58330
#58331 is indiscriminate in what it affects; if we want to allow this for function declarations only, that may be possible, but it sure seems like an extra inconsistency just to avoid writing : void (and how often do people define a noop function?).
hmm, I didn't think of never, so the function expression part is wrong. But I find it annoying to write : void for obviously clear function declarations.
Discussed and we don't want to make it untenable to, in the future, change the rules around function declaration return type inference. For example, it's maybe preferable that
functiondofail(){Debug.fail("oops");}
have an inferred return type of never (as it would if written as a function expression) rather than void.
Activity
jakebailey commentedon Apr 26, 2024
This error is intentional; a function without a return may not always be
void.Is:
This can't be determined without type analysis, so is disallowed under
isolatedDeclarations.Playground Link
RyanCavanaugh commentedon Apr 26, 2024
Correct error for function expressions, but not function declarations - declarations won't infer
neverjakebailey commentedon Apr 26, 2024
#58331 is indiscriminate in what it affects; if we want to allow this for function declarations only, that may be possible, but it sure seems like an extra inconsistency just to avoid writing
: void(and how often do people define a noop function?).Jack-Works commentedon Apr 26, 2024
hmm, I didn't think of
never, so the function expression part is wrong. But I find it annoying to write: voidfor obviously clear function declarations.RyanCavanaugh commentedon May 3, 2024
Discussed and we don't want to make it untenable to, in the future, change the rules around function declaration return type inference. For example, it's maybe preferable that
have an inferred return type of
never(as it would if written as a function expression) rather thanvoid.