Microsoft/TypeScript

SourceFileObject.getNamedDeclarations is missing declarations before methods

Open

#2.137 geöffnet am 25. Feb. 2015

Auf GitHub ansehen
 (7 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: APIDomain: BinderHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

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'

Contributor Guide