ts2kt: private members become public members
- Dominant language
- Kotlin
- Stars
- 591
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to translate babylonjs to kotlin
Private fields in source (*.ts file):
```
export class AxesViewer {
private _xAxis: TransformNode;
private _yAxis: TransformNode;
private _zAxis: TransformNode;
private _scaleLinesFactor = 4;
private _instanced = false;
public scene: Scene;
public scaleLines = 1;
...
```
Converted to private fields (no types!) in the declaration (*.d.ts file)
```
export class AxesViewer {
private _xAxis;
private _yAxis;
private _zAxis;
private _scaleLinesFactor;
private _instanced;
scene: Scene;
scaleLines: number;
```
Most importantly, it private fields become public and accessible for change (*.kt):
```
external open class AxesViewer(scene: Scene, scaleLines: Number = definedExternally, renderingGroupId: Nullable = definedExternally, xAxis: TransformNode = definedExternally, yAxis: TransformNode = definedExternally, zAxis: TransformNode = definedExternally) {
open var _xAxis: Any
open var _yAxis: Any
open var _zAxis: Any
open var _scaleLinesFactor: Any
open var _instanced: Any
open var scene: Any
open var scaleLines: Number
```
I think, by design, private fields cannot be changed from the outside. If it’s difficult to restrict write access, private fields can simply be removed
Contributor guide
No contributing guide indexed for this repository
Research direction
Compare the private fields shown in the source (*.ts), declaration (*.d.ts), and generated (*.kt) examples to trace where their visibility changes. Start by locating the conversion path for class members, then verify that private fields are either inaccessible from outside or omitted from the generated declaration; the examples in this issue should no longer expose them as open properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100