@@ -129,23 +129,26 @@ namespace ts.codefix {
129
129
const { symbol } = leftExpressionType ;
130
130
if ( ! symbol || ! symbol . declarations ) return undefined ;
131
131
132
- const isClass = find ( symbol . declarations , isClassLike ) ;
132
+ const classDeclaration = find ( symbol . declarations , isClassLike ) ;
133
133
// Don't suggest adding private identifiers to anything other than a class.
134
- if ( ! isClass && isPrivateIdentifier ( token ) ) {
134
+ if ( ! classDeclaration && isPrivateIdentifier ( token ) ) {
135
135
return undefined ;
136
136
}
137
137
138
138
// Prefer to change the class instead of the interface if they are merged
139
- const classOrInterface = isClass || find ( symbol . declarations , isInterfaceDeclaration ) ;
139
+ const classOrInterface = classDeclaration || find ( symbol . declarations , isInterfaceDeclaration ) ;
140
140
if ( classOrInterface && ! program . isSourceFileFromExternalLibrary ( classOrInterface . getSourceFile ( ) ) ) {
141
141
const makeStatic = ( ( leftExpressionType as TypeReference ) . target || leftExpressionType ) !== checker . getDeclaredTypeOfSymbol ( symbol ) ;
142
- // Static private identifier properties are not supported yet.
143
- if ( makeStatic && isPrivateIdentifier ( token ) ) return undefined ;
142
+ if ( makeStatic && ( isPrivateIdentifier ( token ) || isInterfaceDeclaration ( classOrInterface ) ) ) {
143
+ return undefined ;
144
+ }
145
+
144
146
const declSourceFile = classOrInterface . getSourceFile ( ) ;
145
147
const inJs = isSourceFileJS ( declSourceFile ) ;
146
148
const call = tryCast ( parent . parent , isCallExpression ) ;
147
149
return { kind : InfoKind . ClassOrInterface , token, parentDeclaration : classOrInterface , makeStatic, declSourceFile, inJs, call } ;
148
150
}
151
+
149
152
const enumDeclaration = find ( symbol . declarations , isEnumDeclaration ) ;
150
153
if ( enumDeclaration && ! isPrivateIdentifier ( token ) && ! program . isSourceFileFromExternalLibrary ( enumDeclaration . getSourceFile ( ) ) ) {
151
154
return { kind : InfoKind . Enum , token, parentDeclaration : enumDeclaration } ;
0 commit comments