fix(KT-43191): add static qualifier for Companion and non-inner objects.
This commit is contained in:
+1
-1
@@ -226,7 +226,7 @@ class ExportModelGenerator(
|
|||||||
type = t,
|
type = t,
|
||||||
mutable = false,
|
mutable = false,
|
||||||
isMember = klass.parent is IrClass,
|
isMember = klass.parent is IrClass,
|
||||||
isStatic = true,
|
isStatic = !klass.isInner,
|
||||||
isAbstract = false,
|
isAbstract = false,
|
||||||
isProtected = klass.visibility == DescriptorVisibilities.PROTECTED,
|
isProtected = klass.visibility == DescriptorVisibilities.PROTECTED,
|
||||||
irGetter = context.mapping.objectToGetInstanceFunction[klass]!!,
|
irGetter = context.mapping.objectToGetInstanceFunction[klass]!!,
|
||||||
|
|||||||
+2
-1
@@ -76,7 +76,8 @@ fun ExportedDeclaration.toTypeScript(indent: String, prefix: String = ""): Strin
|
|||||||
isMember -> (if (isAbstract) "abstract " else "") + (if (!mutable) "readonly " else "")
|
isMember -> (if (isAbstract) "abstract " else "") + (if (!mutable) "readonly " else "")
|
||||||
else -> if (mutable) "let " else "const "
|
else -> if (mutable) "let " else "const "
|
||||||
}
|
}
|
||||||
"$prefix$visibility$keyword$name: ${type.toTypeScript(indent)};"
|
val possibleStatic = if (isMember && isStatic) "static " else ""
|
||||||
|
"$prefix$visibility$possibleStatic$keyword$name: ${type.toTypeScript(indent)};"
|
||||||
}
|
}
|
||||||
|
|
||||||
is ExportedClass -> {
|
is ExportedClass -> {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ declare namespace JS_TESTS {
|
|||||||
function takesO(o: typeof foo.O): number;
|
function takesO(o: typeof foo.O): number;
|
||||||
class KT_37829 {
|
class KT_37829 {
|
||||||
constructor();
|
constructor();
|
||||||
readonly Companion: {
|
static readonly Companion: {
|
||||||
readonly x: number;
|
readonly x: number;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ declare namespace JS_TESTS {
|
|||||||
constructor();
|
constructor();
|
||||||
protected readonly protectedVal: number;
|
protected readonly protectedVal: number;
|
||||||
protected protectedFun(): number;
|
protected protectedFun(): number;
|
||||||
protected readonly protectedNestedObject: {
|
protected static readonly protectedNestedObject: {
|
||||||
};
|
};
|
||||||
protected readonly Companion: {
|
protected static readonly Companion: {
|
||||||
readonly companionObjectProp: number;
|
readonly companionObjectProp: number;
|
||||||
};
|
};
|
||||||
readonly publicVal: number;
|
readonly publicVal: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user