Microsoft/TypeScript
在 GitHub 查看SourceFileObject.getNamedDeclarations is missing declarations before methods
Open
#2,137 创建于 2015年2月25日
BugDomain: APIDomain: BinderHelp Wanted
描述
I'm doing a SourceFileObject.getNamedDeclarations on the following code snippet:
module Mankala {
export class Rectangle {
x: number;
y: number;
width: number;
height: number;
square() {
}
}
}
This returns an array that is missing the property 'height'.
The problem is in SourceFileObject.prototype.getNamedDeclarations
case 125 /* Method */:
var functionDeclaration = node;
if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
var lastDeclaration = namedDeclarations.length > 0 ? namedDeclarations[namedDeclarations.length - 1] : undefined;
if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
if (functionDeclaration.body && !lastDeclaration.body) {
namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
}
}
functionDeclaration.symbol === lastDeclaration.symbol is true as both symbols are undefined. The property 'height' is then replaced by method 'square'