File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,11 +106,23 @@ class PreferConstWalker extends Lint.RuleWalker {
106106 if ( node . kind === ts . SyntaxKind . ObjectLiteralExpression ) {
107107 const pattern = node as ts . ObjectLiteralExpression ;
108108 for ( const element of pattern . properties ) {
109- if ( element . name . kind === ts . SyntaxKind . Identifier ) {
110- this . markAssignment ( element . name as ts . Identifier ) ;
109+ const kind = element . kind ;
110+
111+ if ( kind === ts . SyntaxKind . ShorthandPropertyAssignment ) {
112+ this . markAssignment ( ( element as ts . ShorthandPropertyAssignment ) . name ) ;
111113 }
112- else if ( isBindingPattern ( element . name ) ) {
113- this . visitBindingPatternIdentifiers ( element . name as ts . BindingPattern ) ;
114+ else if ( kind === ts . SyntaxKind . PropertyAssignment ) {
115+ const rhs = ( element as ts . PropertyAssignment ) . initializer ;
116+
117+ if ( rhs . kind === ts . SyntaxKind . Identifier ) {
118+ this . markAssignment ( rhs as ts . Identifier ) ;
119+ }
120+ else if ( rhs . kind === ts . SyntaxKind . ObjectLiteralExpression || rhs . kind === ts . SyntaxKind . ArrayLiteralExpression ) {
121+ this . visitBindingLiteralExpression ( rhs as ts . ObjectLiteralExpression | ts . ArrayLiteralExpression ) ;
122+ }
123+ else {
124+ // Should be an error, but do nothing for now.
125+ }
114126 }
115127 }
116128 }
You can’t perform that action at this time.
0 commit comments