@@ -6,13 +6,11 @@ import dev.adamko.kxstsgen.KxsTsConfig
6
6
/* *
7
7
* Writes [TsElement]s as TypeScript source code.
8
8
*/
9
- abstract class TsSourceCodeGenerator (
10
- val config : KxsTsConfig = KxsTsConfig (),
11
- ) {
9
+ interface TsSourceCodeGenerator {
12
10
13
- abstract fun groupElementsBy (element : TsElement ): String?
11
+ fun groupElementsBy (element : TsElement ): String?
14
12
15
- open fun generateDeclaration (element : TsDeclaration ): String {
13
+ fun generateDeclaration (element : TsDeclaration ): String {
16
14
return when (element) {
17
15
is TsDeclaration .TsEnum -> generateEnum(element)
18
16
is TsDeclaration .TsInterface -> generateInterface(element)
@@ -23,21 +21,21 @@ abstract class TsSourceCodeGenerator(
23
21
}
24
22
}
25
23
26
- abstract fun generateEnum (enum : TsDeclaration .TsEnum ): String
27
- abstract fun generateInterface (element : TsDeclaration .TsInterface ): String
28
- abstract fun generateNamespace (namespace : TsDeclaration .TsNamespace ): String
29
- abstract fun generateTypeAlias (element : TsDeclaration .TsTypeAlias ): String
30
- abstract fun generateTypeUnion (element : TsDeclaration .TsTypeUnion ): String
31
- abstract fun generateTuple (tuple : TsDeclaration .TsTuple ): String
24
+ fun generateEnum (enum : TsDeclaration .TsEnum ): String
25
+ fun generateInterface (element : TsDeclaration .TsInterface ): String
26
+ fun generateNamespace (namespace : TsDeclaration .TsNamespace ): String
27
+ fun generateTypeAlias (element : TsDeclaration .TsTypeAlias ): String
28
+ fun generateTypeUnion (element : TsDeclaration .TsTypeUnion ): String
29
+ fun generateTuple (tuple : TsDeclaration .TsTuple ): String
32
30
33
- abstract fun generateMapTypeReference (tsMap : TsLiteral .TsMap ): String
31
+ fun generateMapTypeReference (tsMap : TsLiteral .TsMap ): String
34
32
35
- abstract fun generatePrimitive (primitive : TsLiteral .Primitive ): String
36
- abstract fun generateTypeReference (typeRef : TsTypeRef ): String
33
+ fun generatePrimitive (primitive : TsLiteral .Primitive ): String
34
+ fun generateTypeReference (typeRef : TsTypeRef ): String
37
35
38
36
open class Default (
39
- config : KxsTsConfig ,
40
- ) : TsSourceCodeGenerator(config) {
37
+ private val config : KxsTsConfig ,
38
+ ) : TsSourceCodeGenerator {
41
39
42
40
43
41
override fun groupElementsBy (element : TsElement ): String {
0 commit comments