@@ -33,80 +33,79 @@ export interface Factory {
33
33
}
34
34
35
35
// eslint-disable-next-line no-unused-vars
36
- export const findStatement = ( context : Pick < ts . TransformationContext , "factory" > ) : Factory [ "findNamespace" ] => (
37
- params : Params$FindStatement ,
38
- ) : ts . Statement | undefined => {
39
- let statement : ts . Statement | undefined ;
40
- params . node . forEachChild ( node => {
41
- if ( ts . isModuleDeclaration ( node ) && node . name . text === params . name ) {
42
- statement = node ;
43
- }
44
- } ) ;
45
- return statement ;
46
- } ;
36
+ export const findStatement =
37
+ ( context : Pick < ts . TransformationContext , "factory" > ) : Factory [ "findNamespace" ] =>
38
+ ( params : Params$FindStatement ) : ts . Statement | undefined => {
39
+ let statement : ts . Statement | undefined ;
40
+ params . node . forEachChild ( node => {
41
+ if ( ts . isModuleDeclaration ( node ) && node . name . text === params . name ) {
42
+ statement = node ;
43
+ }
44
+ } ) ;
45
+ return statement ;
46
+ } ;
47
47
48
- export const create = ( { factory } : Pick < ts . TransformationContext , "factory" > ) : Factory [ "create" ] => (
49
- params : Params$Create ,
50
- ) : ts . ModuleDeclaration => {
51
- const node = factory . createModuleDeclaration (
52
- undefined ,
53
- params . export && [ factory . createModifier ( ts . SyntaxKind . ExportKeyword ) ] ,
54
- factory . createIdentifier ( params . name ) ,
55
- factory . createModuleBlock ( params . statements ) ,
56
- ts . NodeFlags . Namespace ,
57
- ) ;
58
- if ( params . comment ) {
59
- const comment = generateComment ( params . comment , params . deprecated ) ;
60
- return ts . addSyntheticLeadingComment ( node , ts . SyntaxKind . MultiLineCommentTrivia , comment . value , comment . hasTrailingNewLine ) ;
61
- }
62
- return node ;
63
- } ;
48
+ export const create =
49
+ ( { factory } : Pick < ts . TransformationContext , "factory" > ) : Factory [ "create" ] =>
50
+ ( params : Params$Create ) : ts . ModuleDeclaration => {
51
+ const node = factory . createModuleDeclaration (
52
+ params . export && [ factory . createModifier ( ts . SyntaxKind . ExportKeyword ) ] ,
53
+ factory . createIdentifier ( params . name ) ,
54
+ factory . createModuleBlock ( params . statements ) ,
55
+ ts . NodeFlags . Namespace ,
56
+ ) ;
57
+ if ( params . comment ) {
58
+ const comment = generateComment ( params . comment , params . deprecated ) ;
59
+ return ts . addSyntheticLeadingComment ( node , ts . SyntaxKind . MultiLineCommentTrivia , comment . value , comment . hasTrailingNewLine ) ;
60
+ }
61
+ return node ;
62
+ } ;
64
63
65
- export const createMultiple = ( context : Pick < ts . TransformationContext , "factory" > ) : Factory [ "createMultiple" ] => (
66
- params : Params$CreateMulti ,
67
- ) : ts . ModuleDeclaration => {
68
- const names = params . names . reverse ( ) ;
69
- const firstName = names [ 0 ] ;
70
- const restNames = names . slice ( 1 , names . length ) ;
71
- const child = create ( context ) ( {
72
- export : true ,
73
- name : firstName ,
74
- statements : params . statements ,
75
- comment : params . comment ,
76
- deprecated : params . deprecated ,
77
- } ) ;
78
- return restNames . reduce < ts . ModuleDeclaration > ( ( previousStatement , currentName ) => {
79
- return create ( context ) ( {
64
+ export const createMultiple =
65
+ ( context : Pick < ts . TransformationContext , "factory" > ) : Factory [ "createMultiple" ] =>
66
+ ( params : Params$CreateMulti ) : ts . ModuleDeclaration => {
67
+ const names = params . names . reverse ( ) ;
68
+ const firstName = names [ 0 ] ;
69
+ const restNames = names . slice ( 1 , names . length ) ;
70
+ const child = create ( context ) ( {
80
71
export : true ,
81
- name : currentName ,
82
- statements : [ previousStatement ] ,
72
+ name : firstName ,
73
+ statements : params . statements ,
74
+ comment : params . comment ,
75
+ deprecated : params . deprecated ,
83
76
} ) ;
84
- } , child ) ;
85
- } ;
77
+ return restNames . reduce < ts . ModuleDeclaration > ( ( previousStatement , currentName ) => {
78
+ return create ( context ) ( {
79
+ export : true ,
80
+ name : currentName ,
81
+ statements : [ previousStatement ] ,
82
+ } ) ;
83
+ } , child ) ;
84
+ } ;
86
85
87
- export const update = ( context : Pick < ts . TransformationContext , "factory" > ) : Factory [ "update" ] => (
88
- params : Params$Update ,
89
- ) : ts . ModuleDeclaration => {
90
- const { factory } = context ;
91
- const { node, statements } = params ;
92
- if ( node . body && ts . isModuleBlock ( node . body ) ) {
93
- const body = ModuleBlock . update ( context ) ( { node : node . body , statements } ) ;
94
- return factory . updateModuleDeclaration ( node , node . decorators , node . modifiers , node . name , body ) ;
95
- }
96
- return factory . updateModuleDeclaration ( node , node . decorators , node . modifiers , node . name , node . body ) ;
97
- } ;
86
+ export const update =
87
+ ( context : Pick < ts . TransformationContext , "factory" > ) : Factory [ "update" ] =>
88
+ ( params : Params$Update ) : ts . ModuleDeclaration => {
89
+ const { factory } = context ;
90
+ const { node, statements } = params ;
91
+ if ( node . body && ts . isModuleBlock ( node . body ) ) {
92
+ const body = ModuleBlock . update ( context ) ( { node : node . body , statements } ) ;
93
+ return factory . updateModuleDeclaration ( node , node . decorators , node . modifiers , node . name , body ) ;
94
+ }
95
+ return factory . updateModuleDeclaration ( node , node . decorators , node . modifiers , node . name , node . body ) ;
96
+ } ;
98
97
99
- export const addStatements = ( context : Pick < ts . TransformationContext , "factory" > ) : Factory [ "addStatements" ] => (
100
- params : Params$Update ,
101
- ) : ts . ModuleDeclaration => {
102
- const { factory } = context ;
103
- const { node, statements } = params ;
104
- if ( node . body && ts . isModuleBlock ( node . body ) ) {
105
- const body = ModuleBlock . update ( context ) ( { node : node . body , statements : node . body . statements . concat ( statements ) } ) ;
106
- return factory . updateModuleDeclaration ( node , node . decorators , node . modifiers , node . name , body ) ;
107
- }
108
- return factory . updateModuleDeclaration ( node , node . decorators , node . modifiers , node . name , node . body ) ;
109
- } ;
98
+ export const addStatements =
99
+ ( context : Pick < ts . TransformationContext , "factory" > ) : Factory [ "addStatements" ] =>
100
+ ( params : Params$Update ) : ts . ModuleDeclaration => {
101
+ const { factory } = context ;
102
+ const { node, statements } = params ;
103
+ if ( node . body && ts . isModuleBlock ( node . body ) ) {
104
+ const body = ModuleBlock . update ( context ) ( { node : node . body , statements : node . body . statements . concat ( statements ) } ) ;
105
+ return factory . updateModuleDeclaration ( node , node . decorators , node . modifiers , node . name , body ) ;
106
+ }
107
+ return factory . updateModuleDeclaration ( node , node . decorators , node . modifiers , node . name , node . body ) ;
108
+ } ;
110
109
111
110
export const make = ( context : Pick < ts . TransformationContext , "factory" > ) : Factory => {
112
111
return {
0 commit comments