Microsoft/TypeScript

SourceFileObject.getNamedDeclarations is missing declarations before methods

Open

#2,137 建立於 2015年2月25日

在 GitHub 查看
 (7 留言) (0 反應) (0 負責人)TypeScript (48,455 star) (6,726 fork)batch import
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'

貢獻者指南