@@ -1785,36 +1785,6 @@ namespace ts {
1785
1785
}
1786
1786
}
1787
1787
1788
- export function getNameOfDeclaration ( declaration : Declaration ) : DeclarationName {
1789
- if ( ! declaration ) {
1790
- return undefined ;
1791
- }
1792
- if ( declaration . kind === SyntaxKind . BinaryExpression ) {
1793
- const kind = getSpecialPropertyAssignmentKind ( declaration as BinaryExpression ) ;
1794
- const lhs = ( declaration as BinaryExpression ) . left ;
1795
- switch ( kind ) {
1796
- case SpecialPropertyAssignmentKind . None :
1797
- case SpecialPropertyAssignmentKind . ModuleExports :
1798
- return undefined ;
1799
- case SpecialPropertyAssignmentKind . ExportsProperty :
1800
- if ( lhs . kind === SyntaxKind . Identifier ) {
1801
- return ( lhs as PropertyAccessExpression ) . name ;
1802
- }
1803
- else {
1804
- return ( ( lhs as PropertyAccessExpression ) . expression as PropertyAccessExpression ) . name ;
1805
- }
1806
- case SpecialPropertyAssignmentKind . ThisProperty :
1807
- case SpecialPropertyAssignmentKind . Property :
1808
- return ( lhs as PropertyAccessExpression ) . name ;
1809
- case SpecialPropertyAssignmentKind . PrototypeProperty :
1810
- return ( ( lhs as PropertyAccessExpression ) . expression as PropertyAccessExpression ) . name ;
1811
- }
1812
- }
1813
- else {
1814
- return ( declaration as NamedDeclaration ) . name ;
1815
- }
1816
- }
1817
-
1818
1788
export function isLiteralComputedPropertyDeclarationName ( node : Node ) {
1819
1789
return ( node . kind === SyntaxKind . StringLiteral || node . kind === SyntaxKind . NumericLiteral ) &&
1820
1790
node . parent . kind === SyntaxKind . ComputedPropertyName &&
@@ -4738,4 +4708,25 @@ namespace ts {
4738
4708
export function unescapeIdentifier ( identifier : string ) : string {
4739
4709
return identifier . length >= 3 && identifier . charCodeAt ( 0 ) === CharacterCodes . _ && identifier . charCodeAt ( 1 ) === CharacterCodes . _ && identifier . charCodeAt ( 2 ) === CharacterCodes . _ ? identifier . substr ( 1 ) : identifier ;
4740
4710
}
4711
+
4712
+ export function getNameOfDeclaration ( declaration : Declaration ) : DeclarationName | undefined {
4713
+ if ( ! declaration ) {
4714
+ return undefined ;
4715
+ }
4716
+ if ( declaration . kind === SyntaxKind . BinaryExpression ) {
4717
+ const expr = declaration as BinaryExpression ;
4718
+ switch ( getSpecialPropertyAssignmentKind ( expr ) ) {
4719
+ case SpecialPropertyAssignmentKind . ExportsProperty :
4720
+ case SpecialPropertyAssignmentKind . ThisProperty :
4721
+ case SpecialPropertyAssignmentKind . Property :
4722
+ case SpecialPropertyAssignmentKind . PrototypeProperty :
4723
+ return ( expr . left as PropertyAccessExpression ) . name ;
4724
+ default :
4725
+ return undefined ;
4726
+ }
4727
+ }
4728
+ else {
4729
+ return ( declaration as NamedDeclaration ) . name ;
4730
+ }
4731
+ }
4741
4732
}
0 commit comments