mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Gracefully handle accessor declarations in ambient classes.
This commit is contained in:
@@ -4948,7 +4948,7 @@ module ts {
|
||||
}
|
||||
|
||||
checkSourceElement(node.body);
|
||||
if (node.type) {
|
||||
if (node.type && !isAccessor(node.kind)) {
|
||||
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
|
||||
}
|
||||
|
||||
|
||||
@@ -2902,7 +2902,16 @@ module ts {
|
||||
node.typeParameters = sig.typeParameters;
|
||||
node.parameters = sig.parameters;
|
||||
node.type = sig.type;
|
||||
node.body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||
|
||||
// A common error is to try to declare an accessor in an ambient class.
|
||||
if (inAmbientContext && canParseSemicolon()) {
|
||||
parseSemicolon();
|
||||
node.body = createMissingNode();
|
||||
}
|
||||
else {
|
||||
node.body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||
}
|
||||
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user