This repository was archived by the owner on Nov 6, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +28
-4
lines changed Expand file tree Collapse file tree 6 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,11 @@ private fun ObjectTypeToKotlinTypeMapper.buildFqn(symbol: Symbol): KtQualifiedNa
219
219
// TODO: make something better for the case when we have more than one declaration for this symbol.
220
220
// For example see how it work for testData/typeAlias/typeParams.d.ts after renaming `MyHeaders` to `Headers`
221
221
val declaration = symbol.declarations?.singleOrNull()
222
- return declaration?.let { buildFqn(it) } ? : KtQualifiedName (typeChecker.getFullyQualifiedName(symbol))
222
+ return declaration?.let { buildFqn(it) } ? : KtQualifiedName (symbolToString(symbol))
223
+ }
224
+
225
+ private fun ObjectTypeToKotlinTypeMapper.symbolToString (symbol : Symbol ): String {
226
+ return enclosingDeclaration?.let { typeChecker.symbolToString(symbol, it) } ? : typeChecker.symbolToString(symbol)
223
227
}
224
228
225
229
private fun ObjectTypeToKotlinTypeMapper.buildFqn (declaration : Node ): KtQualifiedName ? {
Original file line number Diff line number Diff line change @@ -229,7 +229,8 @@ class TypeScriptToKotlin(
229
229
declarations = innerPackagePartBuilder.members,
230
230
defaultAnnotations = additionalAnnotations,
231
231
typeChecker = typeChecker,
232
- currentPackage = newQualifier.joinToString(" ." )
232
+ currentPackage = newQualifier.joinToString(" ." ),
233
+ enclosingDeclaration = node
233
234
)
234
235
val tr = TypeScriptToKotlin (
235
236
currentPackagePartBuilder = innerPackagePartBuilder,
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ interface ObjectTypeToKotlinTypeMapper {
24
24
fun getKotlinTypeForObjectType (objectType : TypeLiteralNode ): KtType
25
25
fun withTypeParameters (typeParameters : NodeArray <TypeParameterDeclaration >? ): ObjectTypeToKotlinTypeMapper
26
26
val currentPackage: String
27
+ val enclosingDeclaration: Node ?
27
28
val typeChecker: TypeChecker
28
29
// TODO: support recursive type aliases, see recursiveType.d.ts
29
30
val typesInMappingProcess: MutableSet <Type >
@@ -34,6 +35,7 @@ data class ObjectTypeToKotlinTypeMapperImpl(
34
35
val defaultAnnotations : List <KtAnnotation >,
35
36
val declarations : MutableList <KtMember >,
36
37
override val currentPackage : String ,
38
+ override val enclosingDeclaration : Node ? = null ,
37
39
val typeParameterDeclarations : List <TypeParameterDeclaration > = listOf(),
38
40
val cache : MutableMap <String , KtType > = hashMapOf()
39
41
) : ObjectTypeToKotlinTypeMapper {
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ package asTypeAliasInNamespaces.a
4
4
external interface I {
5
5
fun foo (): String
6
6
}
7
- external fun foo (): a. I = definedExternally
7
+ external fun foo (): I = definedExternally
8
8
external fun bar (): b.I = definedExternally
9
9
10
10
// ------------------------------------------------------------------------------------------
@@ -14,5 +14,5 @@ package asTypeAliasInNamespaces.b
14
14
external interface I {
15
15
fun foo (): String
16
16
}
17
- external fun foo (): b. I = definedExternally
17
+ external fun foo (): I = definedExternally
18
18
external fun bar (): a.I = definedExternally
Original file line number Diff line number Diff line change
1
+ package useExportedType
2
+
3
+ external interface StructureType {
4
+ var name: String
5
+ var details: String? get() = definedExternally; set(value) = definedExternally
6
+ }
7
+ external interface Registry {
8
+ fun register (type : StructureType )
9
+ }
Original file line number Diff line number Diff line change
1
+ export type StructureType = {
2
+ name : string ;
3
+ details ?: string ;
4
+ } ;
5
+
6
+ export interface Registry {
7
+ register ( type : StructureType )
8
+ }
You can’t perform that action at this time.
0 commit comments