mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fixed bug where function type literals may omit their '=>'.
This commit is contained in:
parent
2ba3ae9225
commit
96e5bd26c3
@ -1274,7 +1274,18 @@ module ts {
|
||||
var typeParameters = parseTypeParameters();
|
||||
var parameters = parseParameterList(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
|
||||
checkParameterList(parameters);
|
||||
var type = parseOptional(returnToken) ? parseType() : undefined;
|
||||
|
||||
var type: TypeNode;
|
||||
|
||||
if (returnToken === SyntaxKind.EqualsGreaterThanToken) {
|
||||
parseExpected(returnToken);
|
||||
type = parseType();
|
||||
}
|
||||
else if (parseOptional(returnToken))
|
||||
{
|
||||
type = parseType();
|
||||
}
|
||||
|
||||
return {
|
||||
typeParameters: typeParameters,
|
||||
parameters: parameters,
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
==== tests/cases/compiler/functionTypesLackingReturnTypes.ts (2 errors) ====
|
||||
|
||||
// Error (no '=>')
|
||||
function f(x: ()) {
|
||||
~
|
||||
!!! '=>' expected.
|
||||
}
|
||||
|
||||
// Error (no '=>')
|
||||
var g: (param);
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
// Okay
|
||||
var h: { () }
|
||||
|
||||
// Okay
|
||||
var i: { new () }
|
||||
13
tests/cases/compiler/functionTypesLackingReturnTypes.ts
Normal file
13
tests/cases/compiler/functionTypesLackingReturnTypes.ts
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
// Error (no '=>')
|
||||
function f(x: ()) {
|
||||
}
|
||||
|
||||
// Error (no '=>')
|
||||
var g: (param);
|
||||
|
||||
// Okay
|
||||
var h: { () }
|
||||
|
||||
// Okay
|
||||
var i: { new () }
|
||||
Loading…
x
Reference in New Issue
Block a user