Microsoft/TypeScript

SourceFileObject.getNamedDeclarations is missing declarations before methods

Open

#2137 aperta il 25 feb 2015

Vedi su GitHub
 (7 commenti) (0 reazioni) (0 assegnatari)TypeScript (6726 fork)batch import
BugDomain: APIDomain: BinderHelp Wanted

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

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'

Guida contributor