@@ -93,14 +93,16 @@ namespace ts.codefix {
93
93
// (eg: an abstract method or interface declaration), there is a 1-1
94
94
// correspondence of declarations and signatures.
95
95
const signatures = checker . getSignaturesOfType ( type , SignatureKind . Call ) ;
96
+ const needsImplementation = ! isInAmbientContext ( enclosingDeclaration ) ;
96
97
if ( ! some ( signatures ) ) {
97
98
return undefined ;
98
99
}
99
100
100
101
if ( declarations . length === 1 ) {
101
102
Debug . assert ( signatures . length === 1 ) ;
102
103
const signature = signatures [ 0 ] ;
103
- return signatureToMethodDeclaration ( signature , enclosingDeclaration , createStubbedMethodBody ( ) ) ;
104
+ const body = needsImplementation ? createStubbedMethodBody ( ) : undefined ;
105
+ return signatureToMethodDeclaration ( signature , enclosingDeclaration , body ) ;
104
106
}
105
107
106
108
const signatureDeclarations : MethodDeclaration [ ] = [ ] ;
@@ -119,7 +121,7 @@ namespace ts.codefix {
119
121
signatureDeclarations . push ( methodDeclaration ) ;
120
122
}
121
123
}
122
- else {
124
+ else if ( needsImplementation ) {
123
125
Debug . assert ( declarations . length === signatures . length ) ;
124
126
const methodImplementingSignatures = createMethodImplementingSignatures ( signatures , name , optional , modifiers ) ;
125
127
signatureDeclarations . push ( methodImplementingSignatures ) ;
@@ -222,32 +224,17 @@ namespace ts.codefix {
222
224
parameters . push ( restParameter ) ;
223
225
}
224
226
225
- return createStubbedMethod (
226
- modifiers ,
227
- name ,
228
- optional ,
229
- /*typeParameters*/ undefined ,
230
- parameters ,
231
- /*returnType*/ undefined ) ;
232
- }
233
-
234
- export function createStubbedMethod (
235
- modifiers : ReadonlyArray < Modifier > ,
236
- name : PropertyName ,
237
- optional : boolean ,
238
- typeParameters : ReadonlyArray < TypeParameterDeclaration > | undefined ,
239
- parameters : ReadonlyArray < ParameterDeclaration > ,
240
- returnType : TypeNode | undefined ) {
241
227
return createMethod (
242
228
/*decorators*/ undefined ,
243
229
modifiers ,
244
230
/*asteriskToken*/ undefined ,
245
231
name ,
246
232
optional ? createToken ( SyntaxKind . QuestionToken ) : undefined ,
247
- typeParameters ,
233
+ /* typeParameters*/ undefined ,
248
234
parameters ,
249
- returnType ,
250
- createStubbedMethodBody ( ) ) ;
235
+ /*returnType*/ undefined ,
236
+ createStubbedMethodBody ( ) ,
237
+ ) ;
251
238
}
252
239
253
240
function createStubbedMethodBody ( ) {
0 commit comments