@@ -171,7 +171,7 @@ namespace ts.codefix {
171171 if ( isIdentifier ( token ) && isCallExpression ( parent . parent ) ) {
172172 const moduleDeclaration = find ( symbol . declarations , isModuleDeclaration ) ;
173173 const moduleDeclarationSourceFile = moduleDeclaration ?. getSourceFile ( ) ;
174- if ( moduleDeclaration && moduleDeclarationSourceFile && ! program . isSourceFileFromExternalLibrary ( moduleDeclarationSourceFile ) ) {
174+ if ( moduleDeclaration && moduleDeclarationSourceFile && ! isSourceFileFromLibrary ( program , moduleDeclarationSourceFile ) ) {
175175 return { kind : InfoKind . Function , token, call : parent . parent , sourceFile, modifierFlags : ModifierFlags . Export , parentDeclaration : moduleDeclaration } ;
176176 }
177177
@@ -180,7 +180,7 @@ namespace ts.codefix {
180180 return ;
181181 }
182182
183- if ( moduleSourceFile && ! program . isSourceFileFromExternalLibrary ( moduleSourceFile ) ) {
183+ if ( moduleSourceFile && ! isSourceFileFromLibrary ( program , moduleSourceFile ) ) {
184184 return { kind : InfoKind . Function , token, call : parent . parent , sourceFile : moduleSourceFile , modifierFlags : ModifierFlags . Export , parentDeclaration : moduleSourceFile } ;
185185 }
186186 }
@@ -193,7 +193,7 @@ namespace ts.codefix {
193193
194194 // Prefer to change the class instead of the interface if they are merged
195195 const classOrInterface = classDeclaration || find ( symbol . declarations , isInterfaceDeclaration ) ;
196- if ( classOrInterface && ! program . isSourceFileFromExternalLibrary ( classOrInterface . getSourceFile ( ) ) ) {
196+ if ( classOrInterface && ! isSourceFileFromLibrary ( program , classOrInterface . getSourceFile ( ) ) ) {
197197 const makeStatic = ( ( leftExpressionType as TypeReference ) . target || leftExpressionType ) !== checker . getDeclaredTypeOfSymbol ( symbol ) ;
198198 if ( makeStatic && ( isPrivateIdentifier ( token ) || isInterfaceDeclaration ( classOrInterface ) ) ) {
199199 return undefined ;
@@ -207,12 +207,16 @@ namespace ts.codefix {
207207 }
208208
209209 const enumDeclaration = find ( symbol . declarations , isEnumDeclaration ) ;
210- if ( enumDeclaration && ! isPrivateIdentifier ( token ) && ! program . isSourceFileFromExternalLibrary ( enumDeclaration . getSourceFile ( ) ) ) {
210+ if ( enumDeclaration && ! isPrivateIdentifier ( token ) && ! isSourceFileFromLibrary ( program , enumDeclaration . getSourceFile ( ) ) ) {
211211 return { kind : InfoKind . Enum , token, parentDeclaration : enumDeclaration } ;
212212 }
213213 return undefined ;
214214 }
215215
216+ function isSourceFileFromLibrary ( program : Program , node : SourceFile ) {
217+ return program . isSourceFileFromExternalLibrary ( node ) || program . isSourceFileDefaultLibrary ( node ) ;
218+ }
219+
216220 function getActionsForMissingMemberDeclaration ( context : CodeFixContext , info : ClassOrInterfaceInfo ) : CodeFixAction [ ] | undefined {
217221 return info . isJSFile ? singleElementArray ( createActionForAddMissingMemberInJavascriptFile ( context , info ) ) :
218222 createActionsForAddMissingMemberInTypeScriptFile ( context , info ) ;
0 commit comments