@@ -378,28 +378,65 @@ namespace ts {
378
378
}
379
379
380
380
// TODO: Split according to AST nodes.
381
- export function createSignatureDeclaration < T extends SignatureDeclaration > ( kind : SyntaxKind , typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined ) : T ;
382
- export function createSignatureDeclaration < T extends SignatureDeclaration & TypeElement > ( kind : SyntaxKind , typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined , name : string | PropertyName , questionToken : QuestionToken | undefined ) : T ;
383
- export function createSignatureDeclaration < T extends SignatureDeclaration & TypeElement > ( kind : SyntaxKind , typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined , name ?: string | PropertyName , questionToken ?: QuestionToken ) : T {
384
- const signatureDeclaration = createSynthesizedNode ( kind ) as T ;
381
+ export function createSignatureDeclaration ( kind : SyntaxKind , typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined ) {
382
+ const signatureDeclaration = createSynthesizedNode ( kind ) as SignatureDeclaration ;
385
383
signatureDeclaration . typeParameters = asNodeArray ( typeParameters ) ;
386
384
signatureDeclaration . parameters = asNodeArray ( parameters ) ;
387
385
signatureDeclaration . type = type ;
388
- signatureDeclaration . name = asName ( name ) ;
389
- signatureDeclaration . questionToken = questionToken ;
390
386
return signatureDeclaration ;
391
387
}
392
388
393
- // TODO: figure out right type annotation for this function.
394
- export function updateSignatureDeclaration < T extends SignatureDeclaration > ( node : T , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined ) : T ;
395
- export function updateSignatureDeclaration < T extends SignatureDeclaration & TypeElement > ( node : T , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined , name : PropertyName , questionToken : QuestionToken | undefined ) : T ;
396
- export function updateSignatureDeclaration < T extends SignatureDeclaration & TypeElement > ( node : T , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined , name ?: PropertyName , questionToken ?: QuestionToken ) : T {
389
+ export function updateSignatureDeclaration ( node : SignatureDeclaration , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined ) {
390
+ return node . typeParameters !== typeParameters
391
+ || node . parameters !== parameters
392
+ || node . type !== type
393
+ ? updateNode ( createSignatureDeclaration ( node . kind , typeParameters , parameters , type ) , node )
394
+ : node ;
395
+ }
396
+
397
+ export function createFunctionTypeNode ( typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined ) : FunctionTypeNode {
398
+ return createSignatureDeclaration ( SyntaxKind . FunctionType , typeParameters , parameters , type ) as FunctionTypeNode ;
399
+ }
400
+
401
+ export function updateFunctionTypeNode ( node : FunctionTypeNode , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined ) : FunctionTypeNode {
402
+ return < FunctionTypeNode > updateSignatureDeclaration ( node , typeParameters , parameters , type ) ;
403
+ }
404
+
405
+ export function createConstructorTypeNode ( typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined ) : ConstructorTypeNode {
406
+ return createSignatureDeclaration ( SyntaxKind . ConstructorType , typeParameters , parameters , type ) as ConstructorTypeNode ;
407
+ }
408
+ export function updateConstructorTypeNode ( node : ConstructorTypeNode , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined ) : ConstructorTypeNode {
409
+ return < ConstructorTypeNode > updateSignatureDeclaration ( node , typeParameters , parameters , type ) ;
410
+ }
411
+
412
+ export function createCallSignatureDeclaration ( typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined ) : CallSignatureDeclaration {
413
+ return createSignatureDeclaration ( SyntaxKind . CallSignature , typeParameters , parameters , type ) as CallSignatureDeclaration ;
414
+ }
415
+ export function updateCallSignatureDeclaration ( node : CallSignatureDeclaration , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined ) : CallSignatureDeclaration {
416
+ return < CallSignatureDeclaration > updateSignatureDeclaration ( node , typeParameters , parameters , type ) ;
417
+ }
418
+
419
+ export function createConstructSignatureDeclaration ( typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined ) : ConstructSignatureDeclaration {
420
+ return createSignatureDeclaration ( SyntaxKind . ConstructSignature , typeParameters , parameters , type ) as ConstructSignatureDeclaration ;
421
+ }
422
+ export function updateConstructSignatureDeclaration ( node : ConstructSignatureDeclaration , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined ) : ConstructSignatureDeclaration {
423
+ return < ConstructSignatureDeclaration > updateSignatureDeclaration ( node , typeParameters , parameters , type ) ;
424
+ }
425
+
426
+ export function createMethodSignature ( typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined , name : string | PropertyName , questionToken : QuestionToken | undefined ) : MethodSignature {
427
+ const methodSignature = createSignatureDeclaration ( SyntaxKind . MethodSignature , typeParameters , parameters , type ) as MethodSignature ;
428
+ methodSignature . name = asName ( name ) ;
429
+ methodSignature . questionToken = questionToken ;
430
+ return methodSignature ;
431
+ }
432
+
433
+ export function updateMethodSignature ( node : MethodSignature , typeParameters : NodeArray < TypeParameterDeclaration > | undefined , parameters : NodeArray < ParameterDeclaration > , type : TypeNode | undefined , name ?: PropertyName , questionToken ?: QuestionToken ) : MethodSignature {
397
434
return node . typeParameters !== typeParameters
398
435
|| node . parameters !== parameters
399
436
|| node . type !== type
400
437
|| node . name !== name
401
438
|| node . questionToken !== questionToken
402
- ? updateNode ( createSignatureDeclaration < T > ( node . kind , typeParameters , parameters , type , name , questionToken ) , node )
439
+ ? updateNode ( createMethodSignature ( typeParameters , parameters , type , name , questionToken ) , node )
403
440
: node ;
404
441
}
405
442
@@ -502,7 +539,7 @@ namespace ts {
502
539
: node ;
503
540
}
504
541
505
- export function createMethod ( decorators : Decorator [ ] | undefined , modifiers : Modifier [ ] | undefined , asteriskToken : AsteriskToken | undefined , name : string | PropertyName , questionToken : QuestionToken | undefined , typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined , body : Block | undefined ) {
542
+ export function createMethodDeclaration ( decorators : Decorator [ ] | undefined , modifiers : Modifier [ ] | undefined , asteriskToken : AsteriskToken | undefined , name : string | PropertyName , questionToken : QuestionToken | undefined , typeParameters : TypeParameterDeclaration [ ] | undefined , parameters : ParameterDeclaration [ ] , type : TypeNode | undefined , body : Block | undefined ) {
506
543
const node = < MethodDeclaration > createSynthesizedNode ( SyntaxKind . MethodDeclaration ) ;
507
544
node . decorators = asNodeArray ( decorators ) ;
508
545
node . modifiers = asNodeArray ( modifiers ) ;
@@ -525,7 +562,7 @@ namespace ts {
525
562
|| node . parameters !== parameters
526
563
|| node . type !== type
527
564
|| node . body !== body
528
- ? updateNode ( createMethod ( decorators , modifiers , asteriskToken , name , questionToken , typeParameters , parameters , type , body ) , node )
565
+ ? updateNode ( createMethodDeclaration ( decorators , modifiers , asteriskToken , name , questionToken , typeParameters , parameters , type , body ) , node )
529
566
: node ;
530
567
}
531
568
0 commit comments