-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complain when a non-void/any function lacks a return expresson.
In effect this fixes #62. Also - Changes the error message for get accessors lacking return expressions. - Actually checks for return expressions instead of return statements for get-accessors. - Removes fancy quotes. - Corrects errors in the compiler caught by the new check. - Simplified `checkAndAggregateReturnTypes` by extracting it out to `visitReturnStatements`.
- Loading branch information
1 parent
df5c254
commit e9b3fe9
Showing
46 changed files
with
402 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
tests/baselines/reference/conflictingTypeAnnotatedVar.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
==== tests/cases/compiler/conflictingTypeAnnotatedVar.ts (2 errors) ==== | ||
==== tests/cases/compiler/conflictingTypeAnnotatedVar.ts (4 errors) ==== | ||
var foo: string; | ||
function foo(): number { } | ||
~~~ | ||
!!! Duplicate identifier 'foo'. | ||
~~~~~~ | ||
!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. | ||
function foo(): number { } | ||
~~~ | ||
!!! Duplicate identifier 'foo'. | ||
!!! Duplicate identifier 'foo'. | ||
~~~~~~ | ||
!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. |
4 changes: 3 additions & 1 deletion
4
tests/baselines/reference/errorOnContextuallyTypedReturnType.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
==== tests/cases/compiler/errorOnContextuallyTypedReturnType.ts (1 errors) ==== | ||
==== tests/cases/compiler/errorOnContextuallyTypedReturnType.ts (2 errors) ==== | ||
var n1: () => boolean = function () { }; // expect an error here | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! Type '() => void' is not assignable to type '() => boolean': | ||
!!! Type 'void' is not assignable to type 'boolean'. | ||
var n2: () => boolean = function ():boolean { }; // expect an error here | ||
~~~~~~~ | ||
!!! A function whose declared type is neither 'void' nor 'any' must have a 'return' expression or consist of a single 'throw' statement. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.