@@ -113,6 +113,11 @@ namespace ts.codefix {
113
113
}
114
114
type Info = EnumInfo | ClassOrInterfaceInfo ;
115
115
116
+ function isInNodeModulesDeclarationFile ( node : Node ) {
117
+ const sourceFile = getSourceFileOfNode ( node ) ;
118
+ return sourceFile . isDeclarationFile && startsWith ( sourceFile . resolvedPath , "node_modules/" ) || sourceFile . resolvedPath . indexOf ( "/node_modules/" ) !== - 1 ;
119
+ }
120
+
116
121
function getInfo ( tokenSourceFile : SourceFile , tokenPos : number , checker : TypeChecker ) : Info | undefined {
117
122
// The identifier of the missing property. eg:
118
123
// this.missing = 1;
@@ -131,15 +136,15 @@ namespace ts.codefix {
131
136
132
137
// Prefer to change the class instead of the interface if they are merged
133
138
const classOrInterface = find ( symbol . declarations , isClassLike ) || find ( symbol . declarations , isInterfaceDeclaration ) ;
134
- if ( classOrInterface ) {
139
+ if ( classOrInterface && ! isInNodeModulesDeclarationFile ( classOrInterface ) ) {
135
140
const makeStatic = ( ( leftExpressionType as TypeReference ) . target || leftExpressionType ) !== checker . getDeclaredTypeOfSymbol ( symbol ) ;
136
141
const declSourceFile = classOrInterface . getSourceFile ( ) ;
137
142
const inJs = isSourceFileJS ( declSourceFile ) ;
138
143
const call = tryCast ( parent . parent , isCallExpression ) ;
139
144
return { kind : InfoKind . ClassOrInterface , token, parentDeclaration : classOrInterface , makeStatic, declSourceFile, inJs, call } ;
140
145
}
141
146
const enumDeclaration = find ( symbol . declarations , isEnumDeclaration ) ;
142
- if ( enumDeclaration ) {
147
+ if ( enumDeclaration && ! isInNodeModulesDeclarationFile ( enumDeclaration ) ) {
143
148
return { kind : InfoKind . Enum , token, parentDeclaration : enumDeclaration } ;
144
149
}
145
150
return undefined ;
0 commit comments