@@ -171,7 +171,7 @@ namespace ts.codefix {
171
171
if ( isIdentifier ( token ) && isCallExpression ( parent . parent ) ) {
172
172
const moduleDeclaration = find ( symbol . declarations , isModuleDeclaration ) ;
173
173
const moduleDeclarationSourceFile = moduleDeclaration ?. getSourceFile ( ) ;
174
- if ( moduleDeclaration && moduleDeclarationSourceFile && ! program . isSourceFileFromExternalLibrary ( moduleDeclarationSourceFile ) ) {
174
+ if ( moduleDeclaration && moduleDeclarationSourceFile && ! isSourceFileFromLibrary ( program , moduleDeclarationSourceFile ) ) {
175
175
return { kind : InfoKind . Function , token, call : parent . parent , sourceFile, modifierFlags : ModifierFlags . Export , parentDeclaration : moduleDeclaration } ;
176
176
}
177
177
@@ -180,7 +180,7 @@ namespace ts.codefix {
180
180
return ;
181
181
}
182
182
183
- if ( moduleSourceFile && ! program . isSourceFileFromExternalLibrary ( moduleSourceFile ) ) {
183
+ if ( moduleSourceFile && ! isSourceFileFromLibrary ( program , moduleSourceFile ) ) {
184
184
return { kind : InfoKind . Function , token, call : parent . parent , sourceFile : moduleSourceFile , modifierFlags : ModifierFlags . Export , parentDeclaration : moduleSourceFile } ;
185
185
}
186
186
}
@@ -193,7 +193,7 @@ namespace ts.codefix {
193
193
194
194
// Prefer to change the class instead of the interface if they are merged
195
195
const classOrInterface = classDeclaration || find ( symbol . declarations , isInterfaceDeclaration ) ;
196
- if ( classOrInterface && ! program . isSourceFileFromExternalLibrary ( classOrInterface . getSourceFile ( ) ) ) {
196
+ if ( classOrInterface && ! isSourceFileFromLibrary ( program , classOrInterface . getSourceFile ( ) ) ) {
197
197
const makeStatic = ( ( leftExpressionType as TypeReference ) . target || leftExpressionType ) !== checker . getDeclaredTypeOfSymbol ( symbol ) ;
198
198
if ( makeStatic && ( isPrivateIdentifier ( token ) || isInterfaceDeclaration ( classOrInterface ) ) ) {
199
199
return undefined ;
@@ -207,12 +207,16 @@ namespace ts.codefix {
207
207
}
208
208
209
209
const enumDeclaration = find ( symbol . declarations , isEnumDeclaration ) ;
210
- if ( enumDeclaration && ! isPrivateIdentifier ( token ) && ! program . isSourceFileFromExternalLibrary ( enumDeclaration . getSourceFile ( ) ) ) {
210
+ if ( enumDeclaration && ! isPrivateIdentifier ( token ) && ! isSourceFileFromLibrary ( program , enumDeclaration . getSourceFile ( ) ) ) {
211
211
return { kind : InfoKind . Enum , token, parentDeclaration : enumDeclaration } ;
212
212
}
213
213
return undefined ;
214
214
}
215
215
216
+ function isSourceFileFromLibrary ( program : Program , node : SourceFile ) {
217
+ return program . isSourceFileFromExternalLibrary ( node ) || program . isSourceFileDefaultLibrary ( node ) ;
218
+ }
219
+
216
220
function getActionsForMissingMemberDeclaration ( context : CodeFixContext , info : ClassOrInterfaceInfo ) : CodeFixAction [ ] | undefined {
217
221
return info . isJSFile ? singleElementArray ( createActionForAddMissingMemberInJavascriptFile ( context , info ) ) :
218
222
createActionsForAddMissingMemberInTypeScriptFile ( context , info ) ;
0 commit comments