Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from Microsoft/noReturnExpression
Complain when a non-void function lacks a return expresson.
- Loading branch information
Showing
44 changed files
with
478 additions
and
93 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
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 return a value 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 return a value 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 return a value 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
8 changes: 8 additions & 0 deletions
8
tests/baselines/reference/functionWithThrowButNoReturn1.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
==== tests/cases/compiler/functionWithThrowButNoReturn1.ts (1 errors) ==== | ||
function fn(): number { | ||
~~~~~~ | ||
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. | ||
throw new Error('NYI'); | ||
var t; | ||
} | ||
|
Oops, something went wrong.