Skip to content

Function with no return type passes with type signature #234

@kaleidawave

Description

@kaleidawave

The following currently emits no diagnostics

function func(): number {}

playground link

The problem being that the only time return types are checked are around return statements. Not implicit undefined returns.

This should be fairly simple to fix. But there is probably a bit more to think about in terms of where and how the diagnostic is emitted. For example for the following

function func(): number {
  if (Math.random() > 0.8) return 2;
  else {
     something.here();
  }
}

Maybe the diagnostic should be on the else clause?

There are similar conditions for while etc

Metadata

Metadata

Assignees

Labels

blockingThese issues are blocking the checker being used in projectsbugSomething isn't workingcheckingIssues around checkingdiagnosticsrelated to outputting code errorsevents-effectsRelated to operations and side effects

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions