Skip to content
This repository was archived by the owner on Nov 6, 2019. It is now read-only.

Commit 7e224a5

Browse files
epabstSchahen
authored andcommitted
Include "export class ..." in resulting Kotlin even outside of a module (#94)
1 parent b4f50fe commit 7e224a5

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/main/kotlin/ts2kt/TypeScriptToKotlin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class TypeScriptToKotlin(
5656
override val hasMembersOpenModifier = false
5757

5858
fun getAdditionalAnnotations(node: Node): List<KtAnnotation> {
59-
val isShouldSkip = requiredModifier === SyntaxKind.DeclareKeyword && !(node.modifiers?.arr?.any { it.kind === requiredModifier } ?: false )
59+
val isShouldSkip = requiredModifier === SyntaxKind.DeclareKeyword && !(node.modifiers?.arr?.any { it.kind === requiredModifier || it.kind === SyntaxKind.ExportKeyword } ?: false )
6060
if (isShouldSkip) return DEFAULT_FAKE_ANNOTATION
6161

6262
return NO_ANNOTATIONS

testData/class/exportTypes.d.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package exportTypes
2+
3+
external interface FooInterface {
4+
fun methodWithOutArgs()
5+
fun methodWithString(s: String): String
6+
fun methodWithManyArgs(n: Number, settings: Bar): Boolean
7+
}
8+
external open class FooClass {
9+
open fun methodWithOutArgs(): Unit = definedExternally
10+
open fun methodWithString(s: String): String = definedExternally
11+
open fun methodWithManyArgs(n: Number, settings: Bar): Boolean = definedExternally
12+
}

testData/class/exportTypes.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface FooInterface {
2+
methodWithOutArgs();
3+
methodWithString(s: string): string;
4+
methodWithManyArgs(n: number, settings: Bar): boolean;
5+
}
6+
7+
export class FooClass {
8+
methodWithOutArgs();
9+
methodWithString(s: string): string;
10+
methodWithManyArgs(n: number, settings: Bar): boolean;
11+
}

0 commit comments

Comments
 (0)